Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 375

Programming actionscript 3.0
Table of Contents

Advertisement

Once the data has loaded, the
external document are available to use in the URLLoader's
code shows:
private function completeHandler(event:Event):void
{
var loader2:URLLoader = URLLoader(event.target);
trace(loader2.data);
}
If the remote document contains name-value pairs, you can parse the data using the
URLVariables class by passing in the contents of the loaded file, as follows:
private function completeHandler(event:Event):void
{
var loader2:URLLoader = URLLoader(event.target);
var variables:URLVariables = new URLVariables(loader2.data);
trace(variables.dayNames);
}
Each name-value pair from the external file is created as a property in the URLVariables
object. Each property within the variables object in the previous code sample is treated as a
string. If the value of the name-value pair is a list of items, you can convert the string into an
array by calling the
String.split()
var dayNameArray:Array = variables.dayNames.split(",");
If you are loading numeric data from external text files, you need to convert the values
into numeric values by using a top-level function, such as
Instead of loading the contents of the remote file as a string and creating a new URLVariables
object, you could instead set the
properties found in the URLLoaderDataFormat class. The three possible values for the
URLLoader.dataFormat
URLLoaderDataFormat.BINARY
data stored in a ByteArray object.
URLLoaderDataFormat.TEXT
String object.
URLLoaderDataFormat.VARIABLES
encoded variables stored in a URLVariables object.
Event.COMPLETE
method, as follows:
URLLoader.dataFormat
property are as follows:
—The
URLLoader.data
—The
URLLoader.data
—The
event is dispatched, and the contents of the
property, as the following
data
,
int()
property to one of the static
property will contain binary
property will contain text in a
property will contain URL-
URLLoader.data
Working with external data
, or
.
uint()
Number()
375

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents