| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
The LoaderInfo class provides information about a loaded SWF file or a loaded image file
(JPEG, GIF, or PNG). LoaderInfo objects are available for any display object.
The information provided includes load progress, the URLs of the loader and
loaded content, the number of bytes total for the media, and the nominal height and width of the
media.
You can access LoaderInfo objects in two ways:
- The
contentLoaderInfo property of a flash.display.Loader object—
The contentLoaderInfo property is always available for any Loader object.
For a Loader object that has not called the load() or loadBytes()
method, or that has not sufficiently loaded, attempting to access many of the properties of the
contentLoaderInfo property throws an error.
- The
loaderInfo property of a display object.
The contentLoaderInfo property of a Loader object provides information about
the content that the Loader object is loading, whereas the loaderInfo property of
a DisplayObject provides information about the root SWF file for that display object.
The loaderInfo property of an object loaded with a Loader object (a SWF file or
a bitmap) refers to the same LoaderInfo object as the contentLoaderInfo property of the
Loader object. In other words, a LoaderInfo object is shared between a loaded object
file and the Loader object that loaded it. Because the instance of the main class of the SWF file has
no Loader object, the loaderInfo property is the only way to
access the LoaderInfo for the instance of the main class of the SWF file.
The following diagram shows the different uses of the LoaderInfo object—for the instance of the main class of
the SWF file, for the contentLoaderInfo property of a Loader object, and for the loaderInfo
property of a loaded object:
When a loading operation is not complete, some properties of the contentLoaderInfo
property of a Loader object are not available. You can obtain some properties, such as
bytesLoaded, bytesTotal, url, loaderURL,
and applicationDomain. When the loaderInfo object dispatches the
init event, you can access all properties of the loaderInfo object and
the loaded image or SWF file.
Note: All properties of LoaderInfo objects are read-only.
The EventDispatcher.dispatchEvent() method,
which the Loaderinfo class inherits from the EventDispatcher class,
is not applicable to LoaderInfo objects. If you call dispatchEvent()
on a LoaderInfo object, an IllegalOperationError exception is thrown.
View the examples
actionScriptVersion:uint [read-only]
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
The ActionScript version of the loaded SWF file.
The language version is specified by using the enumerations in the
ActionScriptVersion class, such as ActionScriptVersion.ACTIONSCRIPT2
and ActionScriptVersion.ACTIONSCRIPT3.
Note: This property always has a value of either ActionScriptVersion.ACTIONSCRIPT2 or
ActionScriptVersion.ACTIONSCRIPT3. ActionScript 1.0 and 2.0 are
both reported as ActionScriptVersion.ACTIONSCRIPT2 (version 2.0). This property
only distinguishes ActionScript 1.0 and 2.0 from ActionScript 3.0.
Implementation
public function get actionScriptVersion():uint
Throws
| Error — If the file is not downloaded sufficiently to retrieve the requested information.
|
| |
| Error — If the file is not a SWF file.
|
See also
applicationDomain:ApplicationDomain [read-only]
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
When an external SWF file is loaded, all ActionScript 3.0 definitions contained in the loaded
class are stored in the applicationDomain property.
All code in a SWF file is defined to exist in an application domain. The current application
domain is where your main application runs. The system domain contains all application domains,
including the current domain, which means that it contains all Flash Player classes.
All application domains, except the system domain, have an associated parent domain.
The parent domain of your main application's applicationDomain is the system domain.
Loaded classes are defined only when their parent doesn't already define them.
You cannot override a loaded class definition with a newer definition.
For usage examples of application domains, see the "Client System Environment" chapter
in Programming ActionScript 3.0.
Implementation
public function get applicationDomain():ApplicationDomain
Throws
| SecurityError — This security sandbox of the caller is not allowed to access this ApplicationDomain.
|
See also
bytesLoaded:uint [read-only]
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
The number of bytes that are loaded for the media. When this number equals
the value of bytesTotal, all of the bytes are loaded.
Implementation
public function get bytesLoaded():uint
bytesTotal:uint [read-only]
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
The number of compressed bytes in the entire media file.
Before the first progress event is dispatched by
this LoaderInfo object's corresponding Loader object, bytesTotal is 0.
After the first progress event from the Loader object, bytesTotal
reflects the actual number of bytes to be downloaded.
Implementation
public function get bytesTotal():uint
See also
childAllowsParent:Boolean [read-only]
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
Expresses the trust relationship from content (child) to the Loader (parent).
If the child has allowed the parent access, true; otherwise,
false. This property is set to true if the child object
has called the allowDomain() method to grant permission to the parent domain
or if a cross-domain policy is loaded at the child domain that grants permission
to the parent domain. If child and parent are in
the same domain, this property is set to true.
For more information, see the "Flash Player Security" chapter
in Programming ActionScript 3.0.
Implementation
public function get childAllowsParent():Boolean
Throws
| Error — Thrown if the file is not downloaded sufficiently
to retrieve the requested information.
|
content:DisplayObject [read-only]
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
The loaded object associated with this LoaderInfo object.
Implementation
public function get content():DisplayObject
Throws
| SecurityError — If the object accessing this API is prevented from
accessing the loaded object due to security restrictions. This situation can occur,
for instance, when a Loader object attempts to access the contentLoaderInfo.content
property and it is not granted security permission to access the loaded content.
For more information, see the "Flash Player Security" chapter
in Programming ActionScript 3.0.
|
contentType:String [read-only]
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
The MIME type of the loaded file. The value is null if not enough of the file has loaded
for Flash Player to determine the type. The following list gives the possible values:
"application/x-shockwave-flash"
"image/jpeg"
"image/gif"
"image/png"
Implementation
public function get contentType():String
frameRate:Number [read-only]
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
The nominal frame rate, in frames per second, of the loaded SWF file. This
number is often an integer, but need not be.
This value may differ from the actual frame rate in use.
Flash Player only uses a single frame rate for all loaded SWF files at
any one time, and this frame rate is determined by the nominal
frame rate of the main SWF file. Also, Flash Player might not be able to
achieve the main frame rate, depending on hardware, sound synchronization,
and other factors.
Implementation
public function get frameRate():Number
Throws
| Error — If the file is not downloaded sufficiently to retrieve the requested information.
|
| |
| Error — If the file is not a SWF file.
|
height:int [read-only]
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
The nominal height of the loaded file. This value might differ from the actual
height at which the content is displayed, since the loaded content or its parent
display objects might be scaled.
Implementation
public function get height():int
Throws
| Error — If the file is not downloaded sufficiently to retrieve the requested information.
|
loader:Loader [read-only]
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
The Loader object associated with this LoaderInfo object. If this LoaderInfo object
is the loaderInfo property of the instance of the main class of the SWF file, no
Loader object is associated.
Implementation
public function get loader():Loader
Throws
| SecurityError — If the object accessing this API is prevented from
accessing the Loader object because of security restrictions. This can occur,
for instance, when a loaded SWF file attempts to access its loaderInfo.loader
property and it is not granted security permission to access the loading SWF file.
For more information, see the "Flash Player Security" chapter
in Programming ActionScript 3.0.
|
loaderURL:String [read-only]
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
The URL of the SWF file that initiated the loading of the media
described by this LoaderInfo object. For the instance of the main class of the SWF file, this
URL is the same as the SWF file's own URL.
Implementation
public function get loaderURL():String
parameters:Object [read-only]
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
An object that contains name-value pairs that represent the parameters provided
to the loaded SWF file.
You can use a for-in loop to extract all the names and values
from the parameters object.
The two sources of parameters are: the query string in the
URL of the main SWF file, and the value of the FlashVars HTML parameter (this affects
only the main SWF file).
The parameters property replaces the ActionScript 1.0 and 2.0 technique of
providing SWF file parameters as properties of the main timeline.
The value of the parameters property is null for Loader objects
that contain SWF files that use ActionScript 1.0 or 2.0. It is only
non-null for Loader objects that contain SWF files that use ActionScript 3.0.
Implementation
public function get parameters():Object
parentAllowsChild:Boolean [read-only]
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
Expresses the trust relationship from Loader (parent) to the content (child).
If the parent has allowed the child access, true; otherwise,
false. This property is set to true if the parent object
called the allowDomain() method to grant permission to the child domain
or if a cross-domain policy file is loaded at the parent domain granting permission
to the child domain. If child and parent are in
the same domain, this property is set to true.
For more information, see the "Flash Player Security" chapter
in Programming ActionScript 3.0.
Implementation
public function get parentAllowsChild():Boolean
Throws
| Error — Thrown if the file is not downloaded sufficiently
to retrieve the requested information.
|
sameDomain:Boolean [read-only]
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
Expresses the domain relationship between the loader and the content: true if they have
the same origin domain; false otherwise.
Implementation
public function get sameDomain():Boolean
Throws
| Error — Thrown if the file is not downloaded sufficiently
to retrieve the requested information.
|
sharedEvents:EventDispatcher [read-only]
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
An EventDispatcher instance that can be used to exchange events across security boundaries.
Even when the loader and the loadee do not trust one another, both can access sharedEvents.
Implementation
public function get sharedEvents():EventDispatcher
swfVersion:uint [read-only]
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
The file format version of the loaded SWF file.
The file format is specified using the enumerations in the
SWFVersion class, such as SWFVersion.FLASH7 and SWFVersion.FLASH9.
Implementation
public function get swfVersion():uint
Throws
| Error — If the file is not downloaded sufficiently to retrieve the requested information.
|
| |
| Error — If the file is not a SWF file.
|
See also
url:String [read-only]
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
The URL of the media being loaded.
Before the first progress event is dispatched by this LoaderInfo
object's corresponding Loader object, the value of the url property
might reflect only the initial URL specified in the call to the load()
method of the Loader object. After the first progress event, the
url property reflects the media's final URL, after any redirects and relative
URLs are resolved.
Implementation
public function get url():String
See also
width:int [read-only]
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
The nominal width of the loaded content. This value might differ from the actual
width at which the content is displayed, since the loaded content or its parent
display objects might be scaled.
Implementation
public function get width():int
Throws
| Error — If the file is not downloaded sufficiently to retrieve the requested information.
|
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.COMPLETE
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
Dispatched when data has loaded successfully.
The complete event is always dispatched after the init event.
Defines the value of the
type property of a
complete event object.
This event has the following properties:
| Property | Value |
bubbles | false |
cancelable | false; there is no default behavior to cancel. |
currentTarget | The object that is actively processing the Event
object with an event listener. |
target | The network object that has completed loading.
|
See also
Event Object Type: flash.events.HTTPStatusEvent
HTTPStatusEvent.type property = flash.events.HTTPStatusEvent.HTTP_STATUS
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
Dispatched when a network request is made over HTTP and
Flash Player can detect the HTTP status code.
Defines the value of the
type property of a
httpStatus event object.
This event has the following properties:
| Property | Value |
bubbles | false |
cancelable | false; there is no default behavior to cancel. |
currentTarget | The object that is actively processing the Event
object with an event listener. |
status | The HTTP status code returned by the server. |
target | The network object receiving an HTTP status code. |
See also
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.INIT
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
Dispatched when the properties and methods of a loaded SWF file are
accessible. A LoaderInfo object dispatches the init event when the following
two conditions exist:
- All properties and methods associated with the loaded object and those associated
with the LoaderInfo object are accessible.
- The constructors for all child objects have completed.
The init event always precedes the complete event.
Defines the value of the
type property of an
init event object.
This event has the following properties:
| Property | Value |
bubbles | false |
cancelable | false; there is no default behavior to cancel. |
currentTarget | The object that is actively processing the Event
object with an event listener. |
target | The LoaderInfo object associated with the SWF file being loaded. |
See also
Event Object Type: flash.events.IOErrorEvent
IOErrorEvent.type property = flash.events.IOErrorEvent.IO_ERROR
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
Dispatched when an input or output error occurs that causes a load operation to fail.
Defines the value of the
type property of an
ioError event object.
This event has the following properties:
| Property | Value |
bubbles | false |
cancelable | false; there is no default behavior to cancel. |
currentTarget | The object that is actively processing the Event
object with an event listener. |
target | The network object experiencing the input/output error. |
text | Text to be displayed as an error message. |
See also
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.OPEN
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
Dispatched when a load operation starts.
Defines the value of the
type property of an
open event object.
This event has the following properties:
| Property | Value |
bubbles | false |
cancelable | false; there is no default behavior to cancel. |
currentTarget | The object that is actively processing the Event
object with an event listener. |
target | The network object that has opened a connection. |
See also
Event Object Type: flash.events.ProgressEvent
ProgressEvent.type property = flash.events.ProgressEvent.PROGRESS
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
Dispatched when data is received as the download operation progresses.
Defines the value of the
type property of a
progress event object.
This event has the following properties:
| Property | Value |
bubbles | false |
bytesLoaded | The number of items or bytes loaded at the time the listener processes the event. |
bytesTotal | The total number of items or bytes that ultimately will be loaded if the loading process succeeds. |
cancelable | false; there is no default behavior to cancel. |
currentTarget | The object that is actively processing the Event
object with an event listener. |
target | The network object reporting progress. |
See also
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.UNLOAD
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
Dispatched by a LoaderInfo object whenever a loaded object is removed by using the unload()
method of the Loader object, or when a second load is performed by the same Loader object and the
original content is removed prior to the load beginning.
Defines the value of the
type property of an
unload event object.
This event has the following properties:
| Property | Value |
bubbles | false |
cancelable | false; there is no default behavior to cancel. |
currentTarget | The object that is actively processing the Event
object with an event listener. |
target | The LoaderInfo object associated with the SWF file being unloaded or replaced. |
See also
The following example uses the LoaderInfoExample class to display an image on
the stage. This is accomplished by performing the following steps:
- A property
url is created, which is the location and name of the image.
- The class constructor creates a Loader object named
loader.
- The
loader object instantiates an event listener to ensure that the image loads properly.
- The constructor creates a new instance of a URLRequest object,
request,
with url passed so that the file name and location are known.
- The
request object is then passed to the load() method of the
loader object, which loads the image onto the display list.
Important: This example requires that you add a file named Image.gif in the same directory
as the compiled SWF file. Use an image that has an area that fits within the dimensions of the main SWF file.
package {
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.display.Sprite;
import flash.events.*;
import flash.net.URLRequest;
public class LoaderInfoExample extends Sprite {
private var url:String = "Image.gif";
public function LoaderInfoExample() {
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
var request:URLRequest = new URLRequest(url);
loader.load(request);
addChild(loader);
}
private function initHandler(event:Event):void {
var loader:Loader = Loader(event.target.loader);
var info:LoaderInfo = LoaderInfo(loader.contentLoaderInfo);
trace("initHandler: loaderURL=" + info.loaderURL + " url=" + info.url);
}
private function ioErrorHandler(event:IOErrorEvent):void {
trace("ioErrorHandler: " + event);
}
}
}
© 2004-2007 Adobe Systems Incorporated. All rights reserved.
Sun Sep 23 2007, 10:15 PM GMT-07:00
Current page: http://livedocs.adobe.com/livecycle/es/sdkHelp/common/langref/flash/display/LoaderInfo.html