Yeah, that’s cool.

 

I was evaluating the name because when I referenced the button in the loop, it would be “home_btn” and within that button would be a label “homeRollover”.

The reason for the functions was so I could do it all from the actionscript. In your example I would have to manually apply the btnRollOver function to a movieclip yeah?

 

Am I missing something or are there times where it is better not to try and actionscript it all?

Regards,
Zaac Woodhead

Virtual Tours.com.au Pty Ltd
Phone: 1300 366 122
Direct: (03) 9800 7719
Email: [EMAIL PROTECTED]
Web: www.360.com.au

 

-----Original Message-----
From: Mike Pearce [mailto:[EMAIL PROTECTED]]
Sent
:
Tuesday, 20 April 2004 5:40 PM
To: Flash Developers List
Subject: [fugli] Re: creating functions in a for loop

 

Hey Zaac,

 

var buttons = [home_btn, benefits_btn, aboutUs_btn];
var i = buttons.length;
var curBtn;

 

while( i-- ){
    buttons[i].> }

 

function btnRollOver(){
    this.gotoAndPlay("RollOver");
}

 

First thing to notice is it is better to use actual references to the buttons in the first place rather than evaluating strings all the time.

Second, create the function outside the loop then just refence the function. This is better for memoy management as the function is only defined once.

The while(i--) is simply counting backwards from the length of your array. When it gets to 0 - it stops. This is the fastest type of loop you can use.

 

Hope this is of some use. :)

 

Mike

 

 

----- Original Message -----

Sent: Tuesday, April 20, 2004 5:29 PM

Subject: [fugli] creating functions in a for loop

 

yo flashers,

have a menu in flash and trying to loop over each of the buttons and create the rollover function for each of them as a function. having problems to get it happen with the current code .... should i be going about it another way (is there a better way to do it)...

 

// create a list of all the buttons

buttons = ["home","benefits","aboutUs"];

currentButton = 0;

 

// this loop will create the function to go to the rollover state for each of the buttons

for (currentButton; currentButton<4; currentButton++) {

    

// the name of the current button

     tempCurrentButton = buttons[currentButton];

    

     // roll over button effect

     _root[buttons[currentButton]+"_btn"]. () {

           _root[tempButton+"_btn"].gotoAndPlay(tempCurrentButton+"RollOver");

     }

}

---
You are currently subscribed to fugli as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
MXDU2004 + Macromedia DevCon AsiaPac +
Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004

---
You are currently subscribed to fugli as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
MXDU2004 + Macromedia DevCon AsiaPac +
Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004

---
You are currently subscribed to fugli as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004

Reply via email to