Reputation: 161
I have the parent movieClip with multiple children in it.
How do i resize the parent without effecting the children movieClip?
Memo:The children must stay with the parent.
import flash.display.MovieClip;
import flash.events.MouseEvent;
/*The parents*/
var motherFather:MovieClip = new MovieClip();
motherFather.graphics.beginFill(0xAA0022);
motherFather.graphics.drawCircle(40, 40, 40);
motherFather.width=100
motherFather.height=100
motherFather.x=10
motherFather.y=60
addChild(motherFather);
for (var i:Number=1; i<=6;i++){
var children:MovieClip = new MovieClip();
children.graphics.beginFill(0xFF0260);
children.graphics.drawCircle(40, 40, 40);
children.width=30
children.height=30
children.x=10 +(i*30)
children.y=50
motherFather.addChild(children);
}
//CLICK ON STAGE TO RESIZE THE PARENT.
motherFather.addEventListener(MouseEvent.CLICK, ResizeParent);
function ResizeParent(e:MouseEvent){
motherFather.width+=150;
}
Upvotes: 0
Views: 561
Reputation: 9572
More or less similar to Richards' answer, except for the transparency...
You can simply add a transparent background to your motherFather MovieClip and resize that instead of resizing the motherFather MovieClip itself.
var background:Shape = new Shape();
background.name = "background";
background.graphics.beginFill( 0 , 0 );
//add the rest of the graphics functions
motherFather.addChild(background );
function resize(event:MouseEvent):void
{
motherFather.getChildByName("background").with += 150;
}
Also, if you're only going to create shapes, there's no need to use MovieClips , use Shape instances for the children and a Sprite for the container.
Upvotes: 0
Reputation: 10339
Here you go:
import flash.display.MovieClip;
import flash.events.MouseEvent;
/*The parents*/
var motherFather:MovieClip = new MovieClip();
addChild(motherFather);
var fill:MovieClip = new MovieClip();
fill.graphics.beginFill(0xAA0022);
fill.graphics.drawCircle(40, 40, 40);
fill.width=100
fill.height=100
fill.x=10
fill.y=60
motherFather.addChild(fill);
for (var i:Number=1; i<=6;i++){
var children:MovieClip = new MovieClip();
children.graphics.beginFill(0xFF0260);
children.graphics.drawCircle(40, 40, 40);
children.width=30
children.height=30
children.x=10 +(i*30)
children.y=50
motherFather.addChild(children);
addChild(new MovieClip());
}
//CLICK ON STAGE TO RESIZE THE PARENT.
motherFather.addEventListener(MouseEvent.CLICK, ResizeFill);
function ResizeFill(e:MouseEvent){
fill.width+=150;
}
Something like that maybe?
Upvotes: 1