Y
Y
Yeldos Adetbekov2015-02-12 19:17:10
PHP
Yeldos Adetbekov, 2015-02-12 19:17:10

Passing array from php to flash. How to parse response in actionscript 2?

Hello, I can't parse an array that was converted to php that took the content from mysql.
The response itself (Array) from php looks like this:

{friend:'user1',status:1,relationship:'0'};{friend:'user2',status:2,relationship:'Братья'};{friend:'user3',status:0,relationship:'Коллеги'}

Built it to the whims of AS2;
Now I accept it on the Flash side, then I drove it into an array, but in vain each i -th element was a String -th, so I managed to break everything from the bottom of the array into another by converting it to Object (Well, Schaub from {_} get parameters) and store each element in a new array. Checked through typeof(); everything rolls OBJECT Hallelujah, but then I try to pull something out of it, but again this undefined -_-"
I tried to do everything not through a request in PHP, but simply to create an array with objects, everything outputs well. By the way, this is all called associative array . Everything is displayed as and there are plenty of them on the internet, but it's just me with an external array that's complicated.
And one more thing: in order to drive all this String value into an array, I was forced to cut it with a split ; (semicolon) well, to treat them as separate elements.
Please help, I would appreciate it.
Here is the code itself:
var firstarray:Array=new Array();
var friendsarray:Array=new Array() ;
var returner:LoadVars = new LoadVars();
var obj:Object=new Object();

on (release) {
  sendXML = new XML("&login=" + escape(login));
  sendXML.sendAndLoad("data/friends.php",returner,"POST");
  returner.onLoad = function(success:Boolean)
  {
    firstarray = returner.arrayfromserver.split(";");
    firstarray.sortOn(["friend", "status" ]);
    for (i = 0; i < firstarray.length; i++)
    {
      obj=Object(firstarray[i]);
      friendsarray.push(obj);
      pole =pole+friendsarray[i].friend+" ";
    }
  };
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton B, 2015-02-12
@dosya97

There is json in actionscript. Give from php json, parse into actionscript json.

V
vasIvas, 2015-02-12
@vasIvas

Forget about as2, you shouldn't get it out of the grave...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question