Determining when a UILoader component resizes in Flash using ActionScript 3.0

by Peter deHaan on December 19, 2008

in UILoader

The following example shows how you can determine when a Flash ActionScript 3.0 UILoader component has been resized by listening for the resize event (using the static Event.RESIZE constant).

Full code after the jump.

// ActionScript 3.0
/* Requires:
 * - UILoader component in Flash library
 */
import fl.containers.UILoader;
 
var uiLoader:UILoader = new UILoader();
uiLoader.scaleContent = false;
uiLoader.addEventListener(Event.RESIZE, uiLoader_resize);
uiLoader.source = "http://www.helpexamples.com/flash/images/image1.jpg";
addChild(uiLoader);
 
function uiLoader_resize(evt:Event):void {
    var newX:uint = uint((stage.stageWidth - uiLoader.width) / 2);
    var newY:uint = uint((stage.stageHeight - uiLoader.height) / 2);
    uiLoader.move(newX, newY);
}

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Previous post:

Next post: