Resizes the component to the requested size. If the scaleContent property is set to true, the UILoader is not resized.
import fl.containers.UILoader;
var myUILoader:UILoader = new UILoader();
myUILoader.source = "http://www.helpexamples.com/flash/images/image2.jpg";
myUILoader.addEventListener(Event.COMPLETE, completeHandler);
addChild(myUILoader);
function completeHandler(event:Event):void {
var uiLdr:UILoader = event.currentTarget as UILoader;
var image:DisplayObject = uiLdr.content as DisplayObject;
trace("UILoader:", uiLdr.width, uiLdr.height); // 100 100
trace("UILoader.content:", image.width, image.height); // 400 267
uiLdr.setSize(image.width, image.height);
uiLdr.move((stage.stageWidth - image.width) / 2, (stage.stageHeight - image.height) / 2);
}
No comments:
Post a Comment