Skip to main content
GogetaX
Inspiring
February 20, 2018
Question

for/loop question..

  • February 20, 2018
  • 1 reply
  • 378 views

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 has been closed for replies.

1 reply

Inspiring
February 20, 2018

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())

     }

}

GogetaX
GogetaXAuthor
Inspiring
February 20, 2018

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?