Hey!
This all is for a Highscoretable in flash.
Ive tried to find a thread for hours that would be of any help for me, but without success, so I thought of posting my own thread here.
The deal is, I’m trying to set up a function to retrieve variables from a PHP echo.
The echo reads like this:
&user1=babby&score1=19&user2=bobby&score2=18&user3=milson&score3=17&user4=josh&score4=16&user5=sam&score5=15&user6=donald&score6=14&user7=alex&score7=13&user8=mike&score8=12&user9=bob&score9=11&user10=joe&score10=10
The actionscript:
var url:String = "http://b-files.netau.net/getscores.php";
var reqURL:URLRequest = new URLRequest(url);
var loader:URLLoader = new URLLoader(reqURL);
loader.addEventListener(Event.COMPLETE, handleComplete);
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
function handleComplete( event:Event):void
{
var loader:URLLoader = URLLoader(event.target);
trace(loader.data["user1"]);
trace(loader.data["score1"]);
trace("-------------------");
trace(loader.data["user2"]);
trace(loader.data["score2"]);
trace("-------------------");
}
**The output i get is: **
babby
19user2=bobby
-------------------
undefined
18user3=milson
-------------------
Now I wonder why the 2nd userame line says “undefined” and the 1st score line says “19user2=bobby” when i would like the 2nd username to say “bobby” and the 1st score to simply say “19”.
I can’t seem to get this right and I would be very glad if someone here would know what I am doing wrong !
// Joel
ps. sorry for the code wrapping, as my first post i didnt know how to wrap AS3 code correctly.