variable in flash returning as "undefined"
i have a variable in flash that takes its value from a php file using the print function.
The variable is not returning the correct value. I开发者_运维技巧t's returning "undefined". I have checked of both flash and php source code for errors, they both seem the be fine.
anyone know what could be causing this?
php print code:
print "return_sponsor=$sponsor";
flash code:
function completeHandler(event:Event):void{
// Clear the form fields
name_txt.text = "";
email_txt.text = "";
MovieClip(parent).gotoAndPlay("finish");
// Load the response from the PHP file
variables.sponny = event.target.data.return_sponsor;
I've not used AS3 in a while, but this might work.
Replace:
variables.sponny = event.target.data.return_sponsor;
With:
var data:URLVariables = new URLVariables(event.target.data);
variables.sponny = data.return_sponsor;
I don't know what type your sponny variable is but that error is generally returned when Flash can't convert types correctly. It happens to me if I am trying to convert a string to a Number or int (or some other numeric type) and there is a non-numeric symbol in the string (so "12a4" would not be able to convert properly for example).
When you are debugging, place event.target.data.return_sponsor in a String variable and check that it is the correct data. If you can't debug, you may have to find a way to show the data on the screen somehow (maybe by printing them to the form?)
name_txt.text = event.target.data.return_sponsor;
精彩评论