GhostWire Studios - Flash/Flex UI Components Development And Consulting Services
Quality User Interface Controls For Flash Application DevelopmentAspireUI Components

Nov 10 2009

uiImage: Using Embedded And/Or Dynamically Generated BitmapData

Published by sunny at 6:10 am under Aspire UI, Flash, Tips

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.

pixelstats trackingpixel
Share or Bookmark This Post:
  • StumbleUpon
  • email
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Live
  • Yahoo! Buzz
  • Netvibes
  • NewsVine
  • Reddit
  • Slashdot
  • Technorati
  • BlinkList
  • Mixx
  • Diigo
  • Faves
  • Suggest to Techmeme via Twitter
  • Twitter

Other Posts You Might Enjoy:

           

No responses yet

Trackback URI | Comments RSS

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word