Skip to main content
Inspiring
September 25, 2006
Question

duplicating a movieclip wont work properly (v3)

  • September 25, 2006
  • 3 replies
  • 250 views
I have a mc called "Bola_btn" on root and I want to duplicate it using trhis
code.

play_btn = 'play_btn';

Bola_btn.duplicateMovieClip(play_btn, _root.getNextHighestDepth());

var botn = eval(play_btn);
botn._x=200;
botn._y= 300;

It duplicates it but it doesnt move it... what am i doing wrong???

Cheers to everyone.



This topic has been closed for replies.

3 replies

Inspiring
September 25, 2006
Are you looking at the MovieClip.duplicateMovieClip() method? Anyways a bit down it should specifically says, RETURNS and then either something or nothing.
Inspiring
September 25, 2006
Thanks for the answer.

The help says:
duplicateMovieClip(target:MovieClip, newname:String, depth:Number) : Void

That means it doesnt return anything, right?


play_btn is not a child of bola is a movieclip duplicated whick they stay in
the same level, the look the same but the are different. (different
actions).

Is called _btn because is going to ahndle actions but is a mc really.

Hmmm....

Thanks for the interest. :)


"Rothrock" <webforumsuser@macromedia.com> escribió en el mensaje
news:ef8oph$2hr$1@forums.macromedia.com...
>I don't really know how to explain what you are doing wrong other than that
> isn't the way to do it.
>
> Check the help file for the duplicateMovieClip() method. I think it
> returns a
> reference to the clip. If that is the case you could do this:
>
> botn=Bola_btn.duplicateMovieClip(play_btn,1000);
> botn._x=200;
> botn._y=300;
>
> Also I think you can create an init object and give that to the duplicate.
>
> finally if you really want to go this way you could do something like
>
> Bola_btn[play_btn]._x=200;
>
> That is if I'm following correctly and the new button is being duplicated
> as a
> child of Bola_btn.
>
> PS: If Bola_btn is a movieclip why are you giving it a btn suffix?
>


Inspiring
September 25, 2006
I don't really know how to explain what you are doing wrong other than that isn't the way to do it.

Check the help file for the duplicateMovieClip() method. I think it returns a reference to the clip. If that is the case you could do this:

botn=Bola_btn.duplicateMovieClip(play_btn,1000);
botn._x=200;
botn._y=300;

Also I think you can create an init object and give that to the duplicate.

finally if you really want to go this way you could do something like

Bola_btn[play_btn]._x=200;

That is if I'm following correctly and the new button is being duplicated as a child of Bola_btn.

PS: If Bola_btn is a movieclip why are you giving it a btn suffix?
kglad
Community Expert
Community Expert
September 25, 2006
actually, if you used different names for your string and variable, your code would work: