It sends out notifications about the progress of the download, which you can monitor through the bytesLoaded and bytesTotal properties, as well as through dispatched events. When you use this class in Flash Player and in AIR application content in security sandboxes other than then application security sandbox, consider the following security model:.
Indicates the number of bytes that have been loaded thus far during the load operation. Indicates the total number of bytes in the downloaded data. This property contains 0 while the load operation is in progress and is populated when the operation is complete. Also, a missing Content-Length header will result in bytesTotal being indeterminate. The data received from the load operation.
This property is populated only when the load operation is complete. The format of the data depends on the setting of the dataFormat property: TEXT , the received data is a string containing the text of the loaded file. Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
You can register event listeners on all nodes in the display list for a specific type of event, phase, and priority. After you successfully register an event listener, you cannot change its priority through additional calls to addEventListener. To change a listener's priority, you must first call removeListener. Then you can register the listener again with the new priority level. Keep in mind that after the listener is registered, subsequent calls to addEventListener with a different type or useCapture value result in the creation of a separate listener registration.
For example, if you first register a listener with useCapture set to true , it listens only during the capture phase. If you call addEventListener again using the same listener object, but with useCapture set to false , you have two separate listeners: You cannot register an event listener for only the target phase or the bubbling phase.
Those phases are coupled during registration because bubbling applies only to the ancestors of the target node. If you no longer need an event listener, remove it by calling removeEventListener , or memory problems could result. Event listeners are not automatically removed from memory because the garbage collector does not remove the listener as long as the dispatching object exists unless the useWeakReference parameter is set to true.
Copying an EventDispatcher instance does not copy the event listeners attached to it. If your newly created node needs an event listener, you must attach the listener after creating the node. However, if you move an EventDispatcher instance, the event listeners attached to it move along with it. If the event listener is being registered on a node while an event is being processed on this node, the event listener is not triggered during the current phase but can be triggered during a later phase in the event flow, such as the bubbling phase.
If an event listener is removed from a node while an event is being processed on the node, it is still triggered by the current actions. After it is removed, the event listener is never invoked again unless registered again for future processing.
String — The type of event. Function — The listener function that processes the event. This function must accept an Event object as its only parameter and must return nothing , as this example shows: Class-level member functions are not subject to garbage collection, so you can set useWeakReference to true for class-level member functions without subjecting them to garbage collection.
If you set useWeakReference to true for a listener that is a nested inner function, the function will be garbage-collected and no longer persistent. If you create references to the inner function save it in another variable then it is not garbage-collected and stays persistent.
Closes the load operation in progress. Any load operation in progress is immediately terminated. If no URL is currently being streamed, an invalid stream error is thrown. Sends and loads data from the specified URL. The data can be received as text, raw binary data, or URL-encoded variables, depending on the value you set for the dataFormat property. Note that the default value of the dataFormat property is text.
A SWF file in the local-with-filesystem sandbox may not load data from, or provide data to, a resource that is in the network sandbox. For example, a SWF file at www. To load data from a different domain, place a URL policy file on the server hosting the data. You cannot connect to commonly reserved ports.
If the syntax appears to be invalid, the POST operation is subject to the security rules applied to uploads. The file is loaded in a try Here we catch the SecurityError errors. In the loaderCompleteHandler method, a try The readNodes method then recursively goes through all the elements in the nodes of the XML document and appends the xmlTextField text field with a list of the first attributes of all the elements.
Dispatched after all the received data is decoded and placed in the data property of the URLLoader object. The received data may be accessed once this event has been dispatched. Dispatched if a call to URLLoader. For content running in Flash Player, this event is only dispatched if the current Flash Player environment is able to detect and return the status code for the request.
Some browser environments may not be able to provide this information. Note that the httpStatus event if any is sent before and in addition to any complete or error event. Dispatched when the download operation commences following a call to the URLLoader.
Dispatched when data is received as the download operation progresses. Note that with a URLLoader object, it is not possible to access the data until it has been received completely.
So, the progress event only serves as a notification of how far the download has progressed. To access the data before it's entirely downloaded, use a URLStream object.
Also dispatched if a call to URLLoader. To run this example, put a file named urlLoaderExample. That file should only contain the following line of text: Retrieving Data from Server Reading external XML documents. Hide Inherited Public Properties. Show Inherited Public Properties. A reference to the class object or constructor function for a given object instance. Hide Inherited Public Methods. Show Inherited Public Methods. Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
Indicates whether an object has a specified property defined. Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. Indicates whether the specified property exists and is enumerable. Sets the availability of a dynamic property for loop operations. Returns the string representation of this object, formatted according to locale-specific conventions. Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
Click for more information on events. The following example shows how you can load an external text file with URL encoded variables into an ActionScript 3. Example provided by ActionScriptExamples. The following example shows how you can load external text files. If this parameter is omitted, no load operation begins. If specified, the load operation begins immediately see the load entry for more information. The POST operation must be performed in response to a user-initiated action, such as a mouse click or key press.
Event — Dispatched after data has loaded successfully. IOErrorEvent — The load operation could not be completed. ProgressEvent — Dispatched when data is received as the download operation progresses. SecurityErrorEvent — A load operation attempted to retrieve data from a server outside the caller's security sandbox. This may be worked around using a policy file on the server. SecurityErrorEvent — A load operation attempted to load a SWZ file a Adobe platform component , but the certificate is invalid or the digest does not match the component.
Event — Dispatched when a load operation commences. MemoryError — This error can occur for the following reasons: SecurityError — Local untrusted files may not communicate with the Internet. This may be worked around by reclassifying this file as local-with-networking or trusted. SecurityError — You are trying to connect to a commonly reserved port.
Learn more Loading external data. In the following example, an XML files is loaded and the content of its elements' first arguments are displayed in a text field.
This event has the following properties: Property Value bubbles false cancelable false ; there is no default behavior to cancel.More...