Nov 10 2009
uiImage: Using Embedded And/Or Dynamically Generated BitmapData
The uiImage component is used to display non-interactive images.
The source property is a String value and determines the image source, which can be an external image file (property value specifies the file name) or an image embedded in the SWF (property value specifies the class name).
This means that the image source has to be expressed as a String value, which is not always possible. For example, a Bitmap could be dynamically generated during run-time and you may wish to (re)use its BitmapData as the source in uiImage instances.
As of Aspire UI Version 1.3, the uiImage class has a static registerBitmapData() method. You may use this method to register a BitmapData object in the image cache, giving it a unique id. Subsequently, you will be able to use the id as the image source for uiImage instances.
// assuming you have a BitmapData stored in variable logoBitmapData uiImage.registerBitmapData("LOGO", logoBitmapData); var img:uiImage = new uiImage("LOGO"); addChild(img);
Likewise, if an image asset is embedded via the [Embed] meta tag as a nested class member, it may be easier to get an instance of the embedded asset than its String representation.
[Embed(source="../bin/assets/images/logo.png")] private static const logoPNG:Class;
In that case, the registerBitmapData() method can be used:
uiImage.registerBitmapData("LOGO", Bitmap(new logoPNG()).bitmapData); var img:uiImage = new uiImage("LOGO"); addChild(img);
Aspire UI Components
Aspire UI is a library of Actionscript 3.0 (AS3) classes for building flexible and lightweight UI elements in Adobe Flash applications. Key features of the components include easy skinning using PNG image files, automatic tab focus ordering, CSS text styles, and layout management. This is a pure AS3 library with no dependency on the Flex framework.
You may experiment with the various features by downloading the trial version.







