[COLOR=#000000][FONT=Arial]I’m relatively new to AS3, and currently trying to figure out a solution to this problem:[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]I’ve got a launch screen of 25 icons (movie clips, but just static images) in a grid, with buttons behind them. On rollover of each of the icons, I’d like a random selection of the 25 icons to be hidden - EXCEPT for the icon currently rolled over. Then on ROLL_OUT, all 25 icons should become visible again.[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]Any help you can offer is greatly appreciated![/FONT][/COLOR]
The way I would do it is this: Keep an array with all your icons (the things you want to make hidden). When you hover over one, create a copy of this array removing the one youre over. Then, from that array, randomly select those you want to hide and remove the others (this can be done by randomly removing from random indices until you’ve removed n icons, or are left with n icons - however you want it to work). Then loop through that array and hide. Keep that array around, though, since on roll out that array needs to be looped through to reveal those icons again. On reveal you can ditch the array.
Similar to what senocular said you could keep all the items in a list, but it might be simpler to just loop through the list on rollover and as long as the item in the list ISN’T the target, then you could just do a:
items*.alpha = Math.random() < 0.5 ? 1 : 0; //you could change the 0.5 to any number between 0 - 1 to bias it.
then when you roll off you can loop through the array and set all the alphas back to 1 again.