-
Duplicate Moveclip with Button Function
Ok, so I was able to duplicate a movieclip five times. How can I add a button function to the duplicated movieclips?
My current code:
Code:
for (i = 0; i < 5; i++) {
duplicateMovieClip (_root.myMC, "tocbtn" + i, i);
myMC._y = myMC._y + 24;
}
I was thinking something like this...
Code:
for (i = 0; i < 5; i++) {
duplicateMovieClip (_root.myMC, "tocbtn" + i, i);
myMC._y = myMC._y + 24;
myMC.onPress = function() {
getURL("http://www.google.com");
}
}
... but that only adds the link to the last movieclip created.
What am I missing?
Thanks
-
FK'n_dog
loops only update the stage on completion of the last iteration of i, hence only the last clip gets activated.
try this method, hope it helps
Code:
arr = ["www.google.com","www.red.com","www.egg.com",
"www.excite.com","www.888.com"]; // array of URLs
myMC._visible = false; // hide original clip
for (i = 0; i < 5; i++) {
duplicateMovieClip (_root.myMC, "tocbtn" + i, i);
myMC._y += 24;
ref = this["tocbtn" + i];
buttons(ref,i); // pass parameters to function
}
function buttons(ref,i){
ref.onRollOver = function() { trace(this+" - "+arr[i]); };
ref.onPress = function() { getURL("http://"+arr[i],"_blank"); }
};
Last edited by a_modified_dog; 02-02-2007 at 05:03 PM.
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
|