-
For Loops using i
Hi Guys,
I have 20 buttons that I want to define actions for. Instead of defining 20 separate call back functions, I wanted to do this in a FOR loop since all of the buttons share the same action. My buttons are named "btn1_mc" through "btn20_mc". So, I created this for loop:
------BEGIN
for (i=1; i<20; i++) {
buttons_mc.btn[i+_mc].onRollOver = function() {
myColor = new Color(this);
myColor.setRGB(0xFFFF00);
_root.name_txt.text = this.btn+[i+_txt].text;
};
buttons_mc.btn[i+_mc].onRollOut = function() {
myColor.setRGB(0xFFFFFF);
_root.name_txt.text = "";
};
}
------END
But this doesn't work. I traced "i" and it is incremeting properly, but for some reason my buttons aren't responding...any idea what I'm doing wrong?? Do i need to store the button names in an array first?
Thanks,
Josiah
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|