views:

14

answers:

2

The below is my code for trying to clone the MovieClip and it doesn't work. We should see two cirles if the codes is working correctly.

/*The original MovieClip*/
var circle:MovieClip = new MovieClip();
circle.graphics.beginFill(0xAA0022);
circle.graphics.drawCircle(40, 40, 40);
circle.x=10
addChild(circle);

/*CLONE the MovieClip - IT DOES'T WORK FROM HERE DOWN*/
var cloneCirle:MovieClip = new MovieClip();
    cloneCirle=circle
    cloneCirle.x=60 
    addChild(cloneCirle);
A: 

When you do cloneCircle=circle, it's not copying or cloning anything. It's just saying that the variable cloneCircle is another name for your original circle MovieClip. What you need to do is use the Graphics.copyFrom() method.

Try:

var cloneCirle:MovieClip = new MovieClip();
cloneCircle.graphics.copyFrom(circle.graphics);
cloneCirle.x=60;
addChild(cloneCirle);
Mahir
umm I am getting the "Scene 1, Layer 'Layer 1', Frame 1, Line 18 1120: Access of undefined property cloneCircle."
dngo
I got it var cloneCirle:MovieClip = new MovieClip();cloneCirle.graphics.copyFrom(circle.graphics);cloneCirle.x=60;addChild(cloneCirle);
dngo
You spelled cloneCircle wrong... Please mark this answer as accepted (the checkmark)!
Mahir
A: 

LOL, thank you, i can't mark the answer, i am an unregistered user.

dngo