Assume you are referring to something like selecting units in a RTS game or something?
Single sprite
If that's the case the easiest way to do it I think. (Of course depending if you are using multiple selection or just one at the time) But if you just need to select between different sprites, I would use a variable called "Selected_sprite_UID" and here you store the UID of a sprite when you click it for instant.
And then you always use this variable when you need to work with a sprite so you avoid suddenly picking wrong sprites. Since it can only hold one UID at the time, it will make certain of that.
For deselecting you can for instant do like this:
On mouse Right click
Set Selected_sprite_UID = -1
[/code:1pfuv83w]
Since an object can never have a negative UID that will work fine.
[b]Multiple selection[/b]
If you are aiming for multiple selection, you can add a Boolean variable to your sprites called "Selected = False"
[code:1pfuv83w]
On Mouse Left click on Sprite
Set Sprite.Selected = True
[/code:1pfuv83w]
Then when you need to do something with them.
[code:1pfuv83w]
Sprite.Selected = True
For each Sprite
<Do something>
[/code:1pfuv83w]
Deselecting them:
[code:1pfuv83w]
On Mouse right click
Sprite.Selected = True
Set Sprite.Selected = False
[/code:1pfuv83w]
[b]Selection box[/b]
If you need a Selection box, you can do that with a 9-Patch
[code:1pfuv83w]
9-patch overlapping Sprite
Set Sprite.Selected = True
[/code:1pfuv83w]
Deselecting is done the same way as with multiple selection.
To make a working selection box there are some tutorials to make it scale with the mouse as you drag in the tutorial section if I remember correct. However its not that difficult to make.