inkredibl
01-11-2010, 05:00 PM
Hello everybody
I'm trying to put a text from SharedObject and String to a dynamic text field, but the textfield stays empty (or it's whatever I put in var myName:String = ""; ), and it's ignoring any text I define later for the String object. I'm newbie with this and can't get a clue what's wrong.
Here's the code (Flash lite 2.1, AS 2.0):
var mySO:SharedObject = SharedObject.getLocal("myData");
var myText:String = "";
soInitHandler = function(so:SharedObject){
if(mySO.data.myText == undefined){
myText = "Hello World";
}
else {
myText = mySO.data.myText;
mySO.flush();
}
}
SharedObject.addListener("myData", soInitHandler);
myTextField.text = myText;
After this, myTextField should be "Hello World" or anything, but it's empty. What's wrong with this?
(Ps: It works only if I put myTextField.text whithin soInitHandler function, but it's not such a good solution since I need to reuse String data for other text fields later)
Thanks
I'm trying to put a text from SharedObject and String to a dynamic text field, but the textfield stays empty (or it's whatever I put in var myName:String = ""; ), and it's ignoring any text I define later for the String object. I'm newbie with this and can't get a clue what's wrong.
Here's the code (Flash lite 2.1, AS 2.0):
var mySO:SharedObject = SharedObject.getLocal("myData");
var myText:String = "";
soInitHandler = function(so:SharedObject){
if(mySO.data.myText == undefined){
myText = "Hello World";
}
else {
myText = mySO.data.myText;
mySO.flush();
}
}
SharedObject.addListener("myData", soInitHandler);
myTextField.text = myText;
After this, myTextField should be "Hello World" or anything, but it's empty. What's wrong with this?
(Ps: It works only if I put myTextField.text whithin soInitHandler function, but it's not such a good solution since I need to reuse String data for other text fields later)
Thanks