all groups > flash actionscript > june 2004 >
You're in the

flash actionscript

group:

Getting variables from LoadVars in class attribute


Getting variables from LoadVars in class attribute TorinIA
6/23/2004 9:15:38 PM
flash actionscript:
Hi all,

I'm trying to get variables from an external textfile and place them in class
attributes. However, this doesn't seem to work (not the way I'm trying anyway
;-) ). My class definition is shown at the bottom of my message.

I know that the onLoad method is asynchronous, and while loops with
'p_lv.loaded' as test crash Flash. Also, the this.ar_name in the onLoad method
is within the scope of p_lv (and not within the scope of portf).
I just can't think of another way to achieve this. Can anyone help?
TIA,

Vivienne

class Portf {
var name_file:String = "portf.txt";
var name_ar:Array;
var name_str:String;

function Test() {
this._setInitialNames();
}

function _setInitialNames() {
var p_lv:LoadVars = new LoadVars();
p_lv.onLoad = function() {
this.name_ar = this.name_str.split('|');
//trace(this.name_ar.toString()) //shows correct data
}
p_lv.load(this.name_file);
this.name_ar = p_lv.name_ar;
trace(this.name_ar.toString()); //always shows 'undefined'
}
}
Re: Getting variables from LoadVars in class attribute TorinIA
6/24/2004 11:22:17 AM
Anyone? I could really use the help, seeing as I'm new to Flash/ActionScript.

AddThis Social Bookmark Button