actionscript 3 - AS3 Hide Random Object? -
i'm relatively new as3, , trying figure out solution problem:
i've got launch screen of 25 icons (movie clips, static images) in grid, buttons behind them. on rollover of each of icons, i'd random selection of 25 icons hidden - except icon rolled over. on roll_out, 25 icons should become visible again.
any help can offer appreciated!
what need loop through moveiclips have , randomly select set invisible.
to create movieclips invisible set visible
property false
hide them.
since have no supplied of current code, effort create fit needs.
function icon_rollover(e:mouseevent):void { (var i:uint = 0; < holdermc.numchildren; i++) { if (holdermc.getchildat(i) != e.target) { holdermc.getchildat(i).visible = math.random() > 0.5; } } } function icon_rollout(e:mouseevent):void { (var i:uint = 0; < holdermc.numchildren; i++) { holdermc.getchildat(i).visible = true; } } // add together icon_rollover , icon_rollout events each of movieclips
that code should trick. i'm not in position can test code however, there may error or two; basic principle.
holdermc
movieclip each of icons stored. if there other movieclips within holdermc
not icons, more complex code needed, or these non-icons moved container.
when icon_rollover
function called, loop on every movieclip within holdermc
, check see if same e.target
e
event. target
property refers object dispatched event, in case should movieclip rolled over. if current kid not 1 have rolled over, set it's visibility conditional equating whether random number (between 0 , 1) greater .5. i.e. there 50% chance movieclip made invisible.
when icon_rollout
function called, 1 time again loop on every movieclip within holdermc
set visibility true no matter what. create every movieclip in holdermc
visible.
i hope plenty help project. luck!
actionscript-3 flash
No comments:
Post a Comment