Groups | Blog | Home
all groups > flash data integration > may 2005 >

flash data integration : LoadVars inside a class


efrenmgp
5/31/2005 10:57:04 PM
I have a class to lad data from a php script and it loads just fine, my problem
is that I can't pass the data to a property of that class. (see example code):

It loads the id value without any problem, my problem is about scope. the
onLoad() function is a method of the lv object, and from there, the properties
of my class are completely out of scope, at least I don't know how to reach
them.

Anybody can help?


Thanks!!

class test {
public var id:Number = 0;

function test() {
var lv:LoadVars = new LoadVars();

lv.onLoad = function(success:Boolean) {
if (success) {
trace("load was OK");
trace(this.id); // Shows the received value
id = this.id; // This is wrong because 'id' is not static, but it needs
not to be static
// How can I assign lv.id to the id property of the class from here?
} else {
trace("load was not OK");
}
}

lv.load("http://www.domain.com/id.txt");
}
}
somaboy mx
6/2/2005 8:55:30 PM
[quoted text, click to view]

You can use the Delegate class to bring your object within the scope of
the LoadVars event handlers. Look here for more info (applied to XML,
but should work with LoadVars as well):
http://www.kirupa.com/web/xml/XMLspecificIssues3.htm

..soma


AddThis Social Bookmark Button