So I have a container movie clip which will be holding multiple container movie clips. I want to set the size of the main container based on the size of is contents. I was hoping the size could toggle. Here is what Im doing
Code:
/*******LoadBTNS*******/
/*function newvid(event:MouseEvent) {
trace("you clicked me");
var loadit = new Loader();
hold01.addChild(loadit);
loadit.load(new URLRequest("swf001.swf"));
}
my_mc.addEventListener(MouseEvent.MOUSE_DOWN, newvid);*/
/*function newvid2(event:MouseEvent) {
trace("2 you clicked me");
var loadit2 = new Loader();
hold02.addChild(loadit2);
loadit2.load(new URLRequest("swf002.swf"));
}
my_mc2.addEventListener(MouseEvent.MOUSE_DOWN, newvid2);
*/
/*function newvid3(event:MouseEvent) {
trace("3 you clicked me");
var loadit3 = new Loader();
hold03.addChild(loadit3);
loadit3.load(new URLRequest("swf003.swf"));
}
my_mc3.addEventListener(MouseEvent.MOUSE_DOWN, newvid3);*/
/*******UnLoadBTNS*******/
function killParticle(event:Event):void{
//clipHolder.hold02.removeChild(loader2);
clipHolder.hold02.height = 0;
}
my_mc2.addEventListener(MouseEvent.MOUSE_DOWN, killParticle);
clipHolder.height = clipHolder.hold01.content + clipHolder.hold02.content + clipHolder.hold03.content ;
clipHolder.x = 0;
var request:URLRequest = new URLRequest("swf001.swf");
var loader:Loader = new Loader();
loader.load(request);
clipHolder.hold01.addChild(loader);
var request2:URLRequest = new URLRequest("swf002.swf");
var loader2:Loader = new Loader();
loader2.load(request2);
clipHolder.hold02.addChild(loader2);
var request3:URLRequest = new URLRequest("swf003.swf");
var loader3:Loader = new Loader();
loader3.load(request3);
clipHolder.hold03.addChild(loader3);
Any clues on how to achieve this ? Any help would be great.
billy nugz is online now Report Post Edit/Delete Message
You don't need to manually set the height - just position the elements properly and the height will match.
If you are trying to make a background that is always the right size, try adding this to your holding Sprite's class:
Code:
override public function addChild(child:DisplayObject):void{
super.addChild(child);
var w:uint = //calculate your width here
var h:uint = //calculate your height here
with (_backgroundShape.graphics){ // you must define _backgroundShape and add it to your display list earlier
clear();
beginFill(0xAABBCC); // replace this color
drawRect(0, 0, w, h);
}
}
I need the hieght to resize depending on the size of the movieclips within it so say if I click a button and hold2 gets set to zero the container will shink Does that make sense Maybe I should post the fla?
You're really not changing the height - you're repositioning the clips. I would try this:
In your child Classes:
Code:
import flash.events.Event;
...
override public function set height(value:Number):void{
dispatchEvent(new Event(Event.RESIZE, true));
super.height = value;
}
And in your container Class:
Code:
import flash.events.Event;
...
//Put this in your constructor
addEventListener(Event.RESIZE, repositionElements);
...
private function repositionElements(event:Event = null){
//your positioning code goes here.
}