Skip to main content
GogetaX
Inspiring
Feb 20, 2018 8:59 PM UTC
Question

for/loop question..

hey guys, im kinda new with flash, i used it long time ago and still learning few tricks..

i created this nice looking UI with DYNAMIC buttons

example:

BTN_Exit

BTN_Order

BTN_New

etc..

now, i want with in a script to make all those buttons dissapear with an effect..

something like;

for each (var Btn in MyObj)

{

     Print Btn.Name;

}

so my 1st step is to list all the buttons that i created dynamicly on main page..

any ideas how to do that?

This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

Inspiring
Feb 20, 2018 9:45 PM UTC

Add those buttons in an array (or Vector if you can use that) then just loop through it and start your effect on each button with a delay. Many tween engine give the option to delay the tween so increment a delay variable in the loop and pass it along with the tween, if you can't do that then use a timer to delay the start of the tween with same principle of incrementing timing variable then pass it to a new timer, ect .... Or you can do sequential also, when one effect finishes the next one start (gives you less freedom in timing the whole thing). Make a copy of your array (or Vector): mycopy = mymainarray.concat() then start your effect with the first button: startEffect(mycopy.shift()), when the effect is over start again until the array copy is empty:

function endOfEffect():void

{

     if(mycopy.length)

     {

          startEffect(mycopy.shift())

     }

}

Translate
GogetaX
GogetaXAuthor
Inspiring
Feb 20, 2018 9:55 PM UTC

thank you for your faster reply.. but aint there a way to get my compoennt name?

like

if (this.Name == "BTN_Exit"){..}

and also aint there a way to read check for all components that on my parent?

Translate