How can I do this better?


I’ve written a dynamic nav and need a better way to check if all the nav items are moused out.

Basically when a nav item is made it is given a mouse out and mouse in.
When you mouse in it sets a value of ‘0’ in an array and moused out is set a value of ‘1’.

There is then this piece of code
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#808080]//Listen and Move[/COLOR]
mcNavOutTest.[COLOR=#0000FF]onEnterFrame[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR]:[COLOR=#0000FF]Void[/COLOR] [COLOR=#000000]{[/COLOR]
nCounterToFade = [COLOR=#000080]0[/COLOR];
[COLOR=#0000FF]for[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#000000]var[/COLOR] r:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#000080]0[/COLOR]; r < arClosed.[COLOR=#0000FF]length[/COLOR]; r++[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
nCounterToFade += arClosed[COLOR=#000000][[/COLOR]r[COLOR=#000000]][/COLOR];

That adds all the values of the array together. When you mouse out a nav it tests to see if ‘nCounterToFade’ is equal to the length of the array (meaning all values of the array are 1 = all nav items are moused out).

I think its really bad to have a for loop being constantly tested with an onenterframe event. How can I make this better / test if all nav items are moused out. It would have been ideal to create some sort of if statement that checks all nav items but I don’t know how to do this dynamically.

Please help :slight_smile: