Packagecom.ghostwire.ui.controls
Classpublic class uiImage
InheritanceuiImage Inheritance uiComponent Inheritance flash.display.Sprite

The uiImage component is used to display an image, which can either be a movieclip symbol in the library, or an external SWF/GIF/JPG/PNG file.

Multi-State Image
If you supply multiple sources, you will create a multi-state image, ie. an image that changes according to its current state. See the entry for the source property for details.

~ This class is available in Aspire UI Components Lite Edition ~



Public Properties
 PropertyDefined by
 InheritedalignX : Number
Indicates how the component would like to be aligned horizontally within its allocated space.
uiComponent
 InheritedalignY : Number
Indicates how the component would like to be aligned vertically within its allocated space.
uiComponent
 Inheritedbackground : Object
Indicates the style of the background for this component.
uiComponent
 Inheritedcontainer : uiComponent
Indicates the uiComponent instance that contains this instance.
uiComponent
 Inheriteddepth : int
Indicates how deep the component is in the containment hierarchy.
uiComponent
 InheriteddesiredAllocationHeight : int
Indicates the vertical space this component would like to be allocated.
uiComponent
 InheriteddesiredAllocationWidth : int
Indicates the horizontal space this component would like to be allocated.
uiComponent
 Inheritedenabled : Boolean
Indicates whether the component is enabled for user interaction.
uiComponent
 InheritedfillX : Boolean
Indicates whether or not the component should automatically expand or shrink to fill its allocated horizontal space.
uiComponent
 InheritedfillY : Boolean
Indicates whether or not the component should automatically expand or shrink to fill its allocated vertical space.
uiComponent
 InheritedfocusPadding : Object
Indicates the thickness of the interior space from the edge of the component to the focus rectangle.
uiComponent
 InheritedfocusRect : Object
Indicates the class to use when rendering the rectangle around the component to indicate that it is in focus.
uiComponent
 Inheritedheight : Number
Indicates the current height of the component.
uiComponent
  maintainAspectRatio : Boolean
Indicates whether the image should maintain its aspect ratio when resizing via the setSize() method.
uiImage
 Inheritedmargin : Object
Indicates the thickness of the space surrounding the component.
uiComponent
 InheritedmaxHeight : int
Indicates the upper limit for height.
uiComponent
 InheritedmaxWidth : int
Indicates the upper limit for width.
uiComponent
 InheritedminHeight : int
Indicates the lower limit for height.
uiComponent
 InheritedminWidth : int
Indicates the lower limit for width.
uiComponent
 Inheritedpadding : Object
Indicates the thickness of the interior space from the edge of the component to the content area, which is where child components, if any, are contained.
uiComponent
  path : String = "assets/images/"
[static] Indicates the path to the folder containing external image resources (SWF/GIF/JPG/PNG files).
uiImage
 Inheritedskin : String
Indicates the name of the skin to use for this component instance.
uiComponent
  smoothing : Boolean
Controls whether or not the bitmap is smoothed when scaled.
uiImage
  source : String
Indicates the source of the current image displayed.
uiImage
 Inheritedstretch : Boolean
Indicates whether surplus space available in the parent container should be allocated to this component.
uiComponent
 InheritedtextStyle : String
Indicates the style to use for uiText instances contained in this component.
uiComponent
 InheritedtoolTip : Object
Indicates the content (text) of the tooltip that should be shown when the mouse hovers over this control.
uiComponent
 Inheriteduiskin : uiBitmapImage
Returns the uiBitmapImage rendered as the skin - for advanced users only.
uiComponent
 Inheritedvisible : Boolean
Indicates whether or not the component is visible within its container.
uiComponent
 Inheritedwidth : Number
Indicates the current width of the component.
uiComponent
Public Methods
 MethodDefined by
  
uiImage(src:String = "")
Constructor - creates a new uiImage instance.
uiImage
  
clearCache():void
[static] Clears the cache of bitmap images.
uiImage
 Inherited
invalidate(type:String):void
Invalidates this component's "size", "display", "layout" or "textstyle".
uiComponent
 Inherited
move(x:Number, y:Number, noEvent:Boolean = false):void
Moves the component to the specified position, disregarding its allocation.
uiComponent
  
registerBitmapData(id:String, data:BitmapData):void
[static] Registers the specified BitmapData in the image cache, giving it the specified id.
uiImage
 Inherited
removeAllChildren(all:Boolean = false):void
Removes all children from this component.
uiComponent
 Inherited
setFocus(flag:Boolean = true):void
Gives this component instance the focus; the component must be on the display list and has its tabEnabled property set to true, otherwise this method will fail silently.
uiComponent
  
setSize(width:Number, height:Number, noEvent:Boolean = false):void
Sets the width and height of the image explicitly.
uiImage
 Inherited
setVisible(value:Boolean, noEvent:Boolean = false):void
Sets the visibility of this component instance, dispatching a "show" or "hide" event accordingly.
uiComponent
 Inherited
validateNow():void
Validates and render the component instance, and any component instances with depth higher than itself in the validation queue, immediately.
uiComponent
Events
 EventSummaryDefined by
   Dispatched when the image source is changed and the new image is loaded and displayed.uiImage
 Inherited Dispatched when the component's visible property is changed from true to false via calling the setVisible() method.uiComponent
 Inherited Dispatched when the component's position within its parent container has changed via calling the move() method.uiComponent
   Dispatched when data is received as the download of an external image progresses.uiImage
 Inherited Dispatched when the component's size has changed via calling the setSize() method.uiComponent
 Inherited Dispatched when the component's visible property is changed from false to true via calling the setVisible() method.uiComponent
Property detail
maintainAspectRatioproperty
maintainAspectRatio:Boolean  [read-write]

Indicates whether the image should maintain its aspect ratio when resizing via the setSize() method. If set to true, the dimensions specified in the setSize() method becomes the space that will be exerted and the image will be resized within this space while maintaining its original aspect ratio.

The default value is false.

Implementation
    public function get maintainAspectRatio():Boolean
    public function set maintainAspectRatio(value:Boolean):void

See also

pathproperty 
public static var path:String = "assets/images/"

Indicates the path to the folder containing external image resources (SWF/GIF/JPG/PNG files). The string value must end with a trailing slash.

Note: changing this value in the middle of an application does not affect existing images that are already loaded from another path.

The default value is "assets/images/".

smoothingproperty 
smoothing:Boolean  [read-write]

Controls whether or not the bitmap is smoothed when scaled. If true, the bitmap is smoothed when scaled. If false, the bitmap is not smoothed when scaled.

Applicable only if the source is a Bitmap.

Implementation
    public function get smoothing():Boolean
    public function set smoothing(value:Boolean):void
sourceproperty 
source:String  [read-write]

Indicates the source of the current image displayed. The source can either be the name of an external file, or the class name of a movieclip symbol in the library. The component will first attempt to find the symbol in the library. If it is not found, it will attempt to load from external file.

When loading an external image, the value should be the name of the external file in the folder "assets/images/". To load from a different path, prefix the value with "url:", example "url:/images/photos/face.png".

You can supply multiple sources to make a multi-state image (one that changes according to which state it is in). To supply multiple sources, set this property to a string value with the following format:

defaultSource|state1|state1Source|state2|state2Source|state3|state3Source|etc...
For example:
myIcon.source = "icon.png|over|icon_over.png|down|icon_down.png";

The default source is for the default "up" state.

The other possible states are:

  over
  down
  disabled
  emphasized
  emphasized_over
  emphasized_down
  selected
  selected_over
  selected_down
  selected_disabled
  

Implementation
    public function get source():String
    public function set source(value:String):void
Constructor detail
uiImage()constructor
public function uiImage(src:String = "")

Constructor - creates a new uiImage instance.

Parameters
src:String (default = "") — A String value specifying the source of the image. You may supply multiple sources here to create a multi-state image. See the entry for source property for details.

See also

Method detail
clearCache()method
public static function clearCache():void

Clears the cache of bitmap images. When you load external GIF/JPG/PNG bitmap images, the uiImage class will keep a cache of the loaded bitmapData. In this way, the same bitmapData can be reused quickly across different uiImage instances. Calling the clearCache() method clears this cache (forcing image files to be reloaded next time they are requested).

Note: this will not clear the cache for an image that is currently being loaded, since it will not yet be in the cache.

~ Added in version 1.2.3 ~

registerBitmapData()method 
public static function registerBitmapData(id:String, data:BitmapData):void

Registers the specified BitmapData in the image cache, giving it the specified id. Subsequently, you will be able to use the id as an image source.

  uiImage.registerBitmapData("LOGO", logoBitmapData);
  
  var img:uiImage = new uiImage("LOGO");
  addChild(img);

You can also use this method to (unregister) clear the cache of a specific id by passing null for the data parameter.

To clear everything in the cache, use the clearCache() method.

~ Added in version 1.3.0 ~

Parameters
id:String — A String indicating the name to assign to the BitmapData.
 
data:BitmapData — A BitmapData to be registered in the cache.
setSize()method 
public override function setSize(width:Number, height:Number, noEvent:Boolean = false):void

Sets the width and height of the image explicitly.

If you would like to resize the image while retaining its aspect ratio, you should specify only width or height, and set the other side as -1. For example, setSize(100,-1) will resize the image to 100 pixels wide, and the height will be computed based on the original aspect ratio.

The other way to resize the image while maintaining aspect ratio is to set the maintainAspectRatio property to true, in which case the width and height parameters specified when calling this method simply indicates the space within which the image will reside.

Parameters
width:Number
 
height:Number
 
noEvent:Boolean (default = false)

See also

Event detail
changeevent 
Event object type: flash.events.Event

Dispatched when the image source is changed and the new image is loaded and displayed.

progressevent  
Event object type: flash.events.ProgressEvent.PROGRESS

Dispatched when data is received as the download of an external image progresses. You can listen to this event and track the download progress.

This event has the following properties:

PropertyValue
bubblesfalse
bytesLoadedThe accumulated number of bytes loaded at the time the listener processes the event.
bytesTotalThe total number of bytes that will ultimately be loaded if the loading process completes successfully.
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe network object reporting progress.