var a:MovieClip = new MovieClip();
a.graphics.beginFill(0xFF0000);
a.graphics.drawRect(0,0,200,200);
a.graphics.endFill();
addChild(a);
var b:MovieClip = new MovieClip();
b.graphics.beginFill(0x00FF00);
b.graphics.drawRect(0,0,200,200);
b.graphics.endFill();
b.x = 350;
addChild(b);
var c:MovieClip = new MovieClip();
c.graphics.beginFill(0x0000FF);
c.graphics.drawCircle(0,0,50);
c.graphics.endFill();
a.addChild(c);
stage.addEventListener(MouseEvent.CLICK, swapChild);
function swapChild(e:MouseEvent){
if(a.contains(c)){
b.addChild(c);
}else{
a.addChild(c);
}
}
No comments:
Post a Comment