|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
simple duplicatemovieclip question.
scenario:
- i have a movie clip called "ball" - i have a button with the following code: on(press){ for(n=1; n<=5; n++){ ball.duplicateMovieClip("ball01",n); ball01._x = 20; ball01._alpha= 20; } } ============================= I'm trying to learn how to duplicate the clip multiple times (like 5 times. I'm having trouble on what kind of code to write to do this. any suggestions? thanksNadvance. |
|
#2
|
|||
|
|||
|
you have to give your new clips unique names, so stick the counter var on the end of the name:
Code:
on(press){
for(n=1; n<=5; n++){
ball.duplicateMovieClip("ball"+n,n);
this["ball"+n]._x = 20;
this["ball"+n]._alpha= 20;
}
}
|
|
#3
|
|||
|
|||
|
thanks a lot buddy! it works.
my question however, is how the this["ball"+n] syntax works? I know what "this" is, but my understanding of it is it applies to an object refering to itself, but in this case, the code is on the button, so wouldn't the button be considered "this"? i guess its the array like syntax that is confusing me. but thanks! |
|
#4
|
|||
|
|||
|
code on buttons is in the scope of it's parent timeline, so in this case *this* means root
|
|
#5
|
|||
|
|||
|
hmm I'm still confused (i'm pretty newbie-ish ;-) ), but i guess i was expecting to see
eval("ball"+n)._x = n*5; eval("ball"+n)._alpha = 20; instead of this["ball"+n]._x = 20; this["ball"+n]._alpha= 20; ...I guess I just never knew the "this" syntax could be used this way...but im still not sure of the difference??? |
|
#6
|
|||
|
|||
|
usinf eval in that way is really a throwback to flash 4 - since 5 it's better to use dot notation and the square brackets, but I think eval would also work.
|
|
#7
|
|||
|
|||
|
using eval in that way is really a throwback to flash 4 - since 5 it's better to use dot notation and the square brackets, but I think eval would also work.
|
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > simple duplicatemovieclip question. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|