My experience on my daily works... helping others ease each other

Tuesday, November 9, 2010

Reading File in Flex


var loader:URLLoader = new URLLoader();
// telling the loader that we are dealing with variables here.

loader.dataFormat = URLLoaderDataFormat.VARIABLES;

// This is an eventlistener, these are used all the time in AS3
// learn to use them, this basically tells flash to listen to a specific event
// and then call a specific function.
// in Our case we listen for the even called COMPLETE which means it will active
// a function called "loading" when our flash movie has completed.
loader.addEventListener(Event.COMPLETE, loading);

// Here we tell our loading which file to extract from.
loader.load(new URLRequest("content.txt"));

// This is the function that will happen when the eventlistener activates.
// basiclly it says that our text fields called content_1 and _2's text property
// should be equal to loader.data.var_1 and var_2 (as you might remember from the explanation above).
function loading (event:Event):void {
content_1.text = loader.data.var_1
content_2.text = loader.data.var_2
}
Share:

0 comments:

About Me

Somewhere, Selangor, Malaysia
An IT by profession, a beginner in photography

Blog Archive

Blogger templates