Because you are now working with flash.display.* classes, where the
width/height are part of the transform properties and touching them when
the object is empty resets the scale values to 0.  It is one of the
reasons UIComponent overrides width/height.

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of mouhong.lin
Sent: Sunday, April 06, 2008 5:59 AM
To: [email protected]
Subject: [flexcoders] Cannot change Loader object's width and height in
constructor.

 

Hi.

I create an instance of Loader class. Then use it to load a png file.
However, I cannot change the loader's width and height. 

Code:

var _url:URLRequest = new URLRequest("a.png");

var _loader:Loader = new Loader();

_loader.load(_url);

this.addChild(_loader);

If I just type the code above, the png file will be loaded. But if I add
a new line:

_loader.width = 50;

The picture disappeared when I run the application.

If I change the with property in a event listener:

_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoad);

...

private function onLoad(event:Event):void
{
        _loader.width = 50;
}

the loader will change the width property successfully.

I just wanna know why I must place the changing width code in the onLoad
function?

Thanks!

 

Reply via email to