Reputation: 1066
I am trying to get some user data from PHP to AS3.
When I execute my code in AS3 I get this: &levelUser=5&livesUser=5
And its good, it's all the data I want to transfer
But when I try to get only one variable I get this error:
ReferenceError: Error #1069: Property livesUser not found on String and there is no default value.
at petRush_fla::MainTimeline/serverResponse()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
And I don't know who this is happening, I left my code here:
function conectToServer() {
//Conectamos al servidor
loadingNum.text = "Connection to server...";
var zahtjev:URLRequest=new URLRequest("getUserInfo.php");
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, serverResponse);
loader.load(zahtjev);
}
var livesVar:String;
function serverResponse(e:Event):void {
trace(e.target.data.livesUser);
gotoAndStop(2);
}
Upvotes: 0
Views: 58
Reputation: 6751
The data returned is a string, and you need to create a URLVariables instance like this :
function serverResponse(e:Event):void {
var myVariables:URLVariables = new URLVariables(e.target.data);
trace(myVariables.livesUser);
gotoAndStop(2);
}
Also I should note that your string shouldn't begin with a &
, it should be :
levelUser=5&livesUser=5
Upvotes: 3