Displaying an embedded image using a UILoader container in Flash using ActionScript 3.0

by Peter deHaan on November 30, 2008

in Flex, UILoader

The following example shows how you can embed an image using the [Embed] metadata and the Flex SDK and then display the embedded image using a UILoader container in Flash CS4.

Full code after the jump.

Note: The following example requires an image file named flashLogo.png in the same directory as your .FLA file. Since the image gets embedded into the .SWF file, the .PNG file does not need to be copied to the server along with the SWF/HTML.

// ActionScript 3.0
import fl.containers.UILoader;
 
[Embed(source="flashLogo.png")]
const logo_f:Class;
 
var uil:UILoader = new UILoader();
uil.source = logo_f;
uil.scaleContent = false;
uil.move(10, 10);
addChild(uil);

{ 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: