View comments | RSS feed
Methods | Properties | Effects | Events | Styles | Examples Frames | No Frames

mx.controls
Class Loader

Inheritance ImageInheritance ImageInheritance Image
Direct Known Subclasses
           mx.controls.Image

class Loader
extends mx.core.View

The Loader control displays the contents of a specified SWF or JPG file. It has properties that let you scale its contents and set its size. It can also resize itself to fit the size of its contents. By default, content is scaled to fit the size of the Loader control. It can also load content on demand programmatically, and monitor the progress of a load. Although the Loader tag allows loading of images, the Image tag has been tuned for this capability.

A Loader component cannot receive focus. However, content loaded into the Loader component can accept focus and have its own focus interactions. Although the Loader is essentially a control, it extends the View container.

MXML Syntax

The <mx:Loader> tag inherits all the properties of its parent classes, and the following properties:

 <mx:Loader
autoLoad="true|false"
brokenImage="No default."
source="No default."
horizontalAlign="left|center|right"
scaleContent="true|false"
verticalAlign="top|middle|bottom"
complete="Event handler; no default."
progress="Event handler; no default."
/>

Click here to view the Examples

Methods
       load( url: String) :  Void
Begins loading an image or SWF file.

Methods inherited from class mx.core.View
childLoaded   constructObject2   createChild   createChildren   destroyAllChildren   destroyChild   destroyChildAt   draw   getBorderMetrics   getChildAt   getChildIndex   getViewMetrics   init   layoutChildren   layoutChrome   setChildIndex  

Methods inherited from class mx.core.UIComponent
drawFocus   getFocus   getFocusManager   setEnabled   setFocus  

Methods inherited from class mx.core.UIObject
addEventListener   applyProperties   buildDepthTable   commitProperties   constructObject2   createAccessibilityImplementation   createChildAtDepth   createChildren   createClassChildAtDepth   createClassObject   createEmptyObject   destroyObject   dispatchEvent   doLater   draw   drawRect   executeBindings   fillRect   findNextAvailableDepth   getRepeaterItem   getStyle   handleEvent   init   invalidate   invalidateLayout   invalidateProperties   invalidateSize   invalidateStyle   layoutChildren   measure   move   redraw   removeEventListener   setDepthAbove   setDepthBelow   setMask   setSize   setSizeNoLayout   setStyle   swapDepths  



Properties
       autoLoad: Boolean
If true, the content loads automatically.
       brokenImage: String
Image to display if load fails.
       bytesLoaded: Number    [Read-Only]
Number of bytes of the image or SWF file already loaded.
       bytesTotal: Number    [Read-Only]
Total size of the image or SWF file.
       content: mx.core.UIComponent    [Read-Only]
Content of the Loader.
       percentLoaded: Number    [Read-Only]
Percent of the image or SWF file already loaded.
       scaleContent: Boolean
If true, the content scales to fit the Loader.
       source: String
Specification of content location.
staticversion: String
Version string for this class.

Properties inherited from class mx.core.View
baselinePosition   className   numChildren   version  

Properties inherited from class mx.core.UIComponent
enabled   errorString   tabEnabled   tabIndex   version  

Properties inherited from class mx.core.UIObject
alpha   baselinePosition   className   depth   documentDescriptor   height   heightFlex   id   instanceIndices   isDocument   kStretch   layoutHeight   layoutWidth   maxHeight   maxWidth   minHeight   minWidth   mouseX   mouseY   nestLevel   oldHeight   oldWidth   oldX   oldY   parent   parentApplication   parentDocument   percentHeight   percentWidth   preferredHeight   preferredWidth   repeaterIndices   scaleX   scaleY   styleName   tabEnabled   toolTip   version   visible   width   widthFlex   x   y  



Effects

Effects inherited from class mx.core.UIComponent
focusInEffect   focusOutEffect  

Effects inherited from class mx.core.UIObject
creationCompleteEffect   hideEffect   mouseDownEffect   mouseOutEffect   mouseOverEffect   mouseUpEffect   moveEffect   resizeEffect   showEffect  



Events
completeBroadcast when content loading is complete. This event is broadcast regardless of whether the load was triggered by an autoload or an explicit load() call. The event object's target property contains a reference to the component that triggered the event. The event object's type property contains the name of the event, complete.
progressBroadcast when content is loading. This event is broadcast regardless of whether the load was triggered by an autoload or an explicit load() call. Note: The progress event is not guaranteed to be dispatched. The complete event may be received, without any progress events being dispatched. This can happen when the loaded content is a local file. The event object's target property contains a reference to the component that triggered the event. The event object's type property contains the name of the event, progress.

Events inherited from class: mx.core.View
childCreated  childDestroyed  childIndexChanged 

Events inherited from class: mx.core.UIComponent
focusIn  focusOut  invalid  keyDown  keyUp  valid  valueCommitted 

Events inherited from class: mx.core.UIObject
creationComplete  dragComplete  dragDrop  dragEnter  dragExit  dragOver  draw  effectEnd  effectStart  hide  hideToolTip  initialize  load  mouseChangeSomewhere  mouseDown  mouseDownSomewhere  mouseMove  mouseMoveSomewhere  mouseOut  mouseOver  mouseUp  mouseUpSomewhere  move  resize  show  showToolTip  unload 



Styles
horizontalAlign CSS Inheritance: no
Horizontal alignment of the image when it does not have a one-to-one aspect ratio. The default value is left. Possible values are left, center, and right.
verticalAlign CSS Inheritance: no
Vertical alignment of the image when it does not have a one-to-one aspect ratio. The default value is top. Possible values are top, middle, and bottom.

Styles inherited from class mx.core.UIComponent
backgroundAlpha   backgroundColor   backgroundDisabledColor   backgroundImage   backgroundSize   barColor   borderCapColor   borderColor   borderSides   borderStyle   borderThickness   cornerRadius   disabledColor   dropShadow   errorColor   fillColors   highlightColor   modalTransparency   scrollTrackColor   selectedFillColors   shadowCapColor   shadowColor   shadowDirection   shadowDistance   symbolBackgroundColor   symbolBackgroundDisabledColor   symbolBackgroundPressedColor   symbolColor   symbolDisabledColor   themeColor  

Styles inherited from class mx.core.UIObject
color   fontFamily   fontSize   fontStyle   fontWeight   horizontalGap   leading   marginLeft   marginRight   textAlign   textDecoration   textIndent   verticalGap  



Method Detail

load

load( url: String) :  Void

Begins loading an image or SWF file. The url parameter can only point to a SWF or JPG image.

Parameters
    url: String - Absolute or relative URL of JPG or SWF file to load.



Property Detail

autoLoad

autoLoad: Boolean  

If true, the content loads automatically. If false, you must call the load method. The default value is true.


brokenImage

brokenImage: String  

Image to display if load fails. This image will not display immediately and often takes a number of minutes before appearing.


bytesLoaded

bytesLoaded: Number   [Read-Only]

Number of bytes of the image or SWF file already loaded.


bytesTotal

bytesTotal: Number   [Read-Only]

Total size of the image or SWF file.


content

content: mx.core.UIComponent   [Read-Only]

Content of the Loader. This property cotains the object that represents the contents what was loaded. For example, if it a SWF was specified, then this property contains a MovieClip.


percentLoaded

percentLoaded: Number   [Read-Only]

Percent of the image or SWF file already loaded.


scaleContent

scaleContent: Boolean  

If true, the content scales to fit the Loader. If false, the Loader scales to fit the content. The default value is true.


source

source: String  

Specification of content location. The source property takes the following form:
source="relativeOrAbsoluteURL"
Flex loads the referenced file at runtime; it is not packaged as part of the generated SWF file. Thus, the source property only supports the loading of JPEG images and SWF files.


version

static  version: String  

Version string for this class.


Examples
SimpleLoader.mxml
<?xml version="1.0"?>
<!-- Simple example to demonstrate the Loader control -->
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" backgroundColor="#FFFFFF">

    <mx:Panel title="Loader Panel">

        <mx:Loader id="Load" source="@Embed('icecreampint.jpg')" height="150" width="150"/>

    </mx:Panel>

</mx:Application>
       




Comments


Greg Fuller said on Feb 15, 2005 at 12:37 PM :
The contentPath property does not appear to be documented for the Loader class.
halL said on Feb 16, 2005 at 5:55 AM :
The contentPath property is deprecated and will be removed from the documentation.
You should use the source property, which is synonymous with contentPath, instead.
No screen name said on Jun 6, 2005 at 2:11 PM :
i have a situation where i am not sure if the image string i'm supplied with will point to an image. i want to test if the image exists and if it doesn't default to a generic image.

//my plan was to create a loader
var tLoader = new Loader();
//load the string url
tLoader.load(url);
//then test the loader to see if it actually loaded anything
if(tLoader.bytesTotal == 0){...}

this doesn't work..
i've tried binding a listener to the complete event which doesn't work. is there a reliable means of testing to see if you are loading an image file?
thx e
mpeterson said on Jun 8, 2005 at 8:03 AM :
Regarding the previous comment :
Please note that Livedocs is not a support mechanism. It is for commenting on the documentation. For support, please visit the Flex support center at http://www.macromedia.com/support/flex/ or the flexcoders mailing list at http://www.flexcoders.org/index.html.

Thanks,

Mike Peterson
Flex documentation team
No screen name said on Jul 16, 2006 at 12:02 PM :
I think this is actually a mistake in the code, not the documentation, but the docs don't match what's in the code. I am trying to subclass Image and overload the layout methods. My method signatures match those in UIObject. However, two of them, commitProperties and layoutChildren, cause warnings because my methods, for instance:

public function commitProperties() : Void

hide the ancestor method. commitProperties and layoutChildren in Loader do not have return values specified, and so my correctly specifying Void for the return type causes the error. The other six functions (the invalidates, measure, draw) do not have this problem, but Loader seems to have incorrectly overloaded commitProperties and layoutChildren.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flex/15/asdocs_en/mx/controls/Loader.html