hi,
i am working on an image gallery, in which the thumbnails will float up and down randomly, with the stageHeight as border.
This works all fine, but now I wanted to add it to a container, so I can change it to a new size (making it bounce not on the entire stageHeight).
Pls see code below, just a simple example without the floating function and only two testboxes, but enough to show the problem:
var container:MovieClip = new MovieClip();
addChild(container);
//including the following lines doesn't display anything anymore - leaving it out //works fine:
//container.height = 400;
//container.width = 400;
var firstBox:TestBox = new TestBox();
var secBox:TestBox = new TestBox();
container.addChild(firstBox);
container.addChild(secBox);
firstBox.x = 50;
secBox.x = 350;
Leaving the 2 lines in question out sizes the container to the whole stage again ...
pixum
I spotted your "pixum says hi" thread and thought I would say hello and welcome to Ultrashock while I'm in this thread.
Getting into the specifics about how display objects are resized in Flash is well beyond the scope of this thread, but I will try to nutshell it here. When you set the width or height of a display object it doesn't actually give the display object a fixed width or height, what happens is the scaleX and scaleY properties are changed so that the content is scaled to visually match the specified width and height (relative to the scaleX and scaleY values of the parent display object).
Because you are setting the width and height of your container while it is empty the scaleX and scaleY properties are being reduced to 0 (zero).
var container:MovieClip = new MovieClip(); setContainerSize( container, 400, 400 ); trace( container.width ); // 400 trace( container.height ); // 400 trace( container.scaleX ); // 1 trace( container.scaleY ); // 1 function setContainerSize( target:MovieClip, w:int, h:int ):void { target.graphics.clear(); // top-left target.graphics.beginFill( 0 ); target.graphics.drawRect( 0, 0, 0, 0 ); target.graphics.endFill(); // bottom-right target.graphics.beginFill( 0 ); target.graphics.drawRect( w, h, 0, 0 ); target.graphics.endFill(); }