Noob question on how to adapt a code in as2 to flash 5
I have this code in as2, it works great, but I need to adapt it to fl开发者_开发百科ash5 myName is the variable asociated to a dinamic text on the flash, it shows the hello but never the good bye even if I comment the line myName="hello"; how can I replicate this to work on flash 5?
myName="hello";
myVars = new LoadVars();
myVars.load("getScores.php");
myVars.onData = function(raw) {
myName="good bye";
}
LoadVars
is a class of Actionscript 2.0 so it is not supported in Flash 5.
You should use instead the loadVariables
method of Actionscript 1.0 and using a code such as
onClipEvent(load){
this.loadVariables("file.txt");
}
onClipEvent(data){
test = "variable: " + variable;
}
with this code the data
event is fired after variables loading. You must put this code on a movieclip instance (not on timeline).
It appears your OnData function never fires, thus the Good Bye text never displays.
try replacing myVars.onData
with the following:
myVars.onLoad = function (success) {
if (success) {
// Call your parser here perhaps
} else {
// The data didn?t load at all. Display error
}
}
This will either fix the problem or assist you in finding the problem.
精彩评论