Groups | Blog | Home
all groups > flash actionscript > july 2007 >

flash actionscript : Newbie question: Fun with Arrays


zend999
7/20/2007 6:32:09 PM
I can't figure out why this script will not work. It's an incredibly
simple set-up. 8 buttons, each with two behaviors; onRollOver and
onRelease. Following is the entirety of the script. It WILL work if I
abandon the arrays and type out the onRollOver/onRelease functions 8
times. But c'mon, why won't the arrays work? I know it must be
something really obvious. Thanks for any advice!

for (var i:Number = 0; i<8; i++) {
button[i].onRollOver = function() {
gotoAndPlay("hOver");
};
button[i].onRelease = function() {
gotoAndPlay(frame[i]);
};
}
var button:Array = new Array("bio", "disc", "live", "video", "news",
"photo", "links", "contact");
var frame:Array = new Array("bClick", "dClick", "lClick", "vClick",
"nClick", "pClick", "kClick", "cClick");
stop();
Ciaran
7/20/2007 9:10:40 PM

[quoted text, click to view]

Have you tried defining the arrays before you try to call them??

AddThis Social Bookmark Button