Flash As3.0 PHP Variables?
Posted
by user311421
on Stack Overflow
See other posts from Stack Overflow
or by user311421
Published on 2010-04-07T21:55:43Z
Indexed on
2010/04/13
20:43 UTC
Read the original article
Hit count: 363
Is it possible to make php variables public and accessible anywhere on the timeline?
The script I included works fine if I set it as the document class only (it won't work if I try importing it). The variables pass the text to dynamic text fields on the main timeline.
The problem: It will pull the information and display it when the SWF first loads but if I move to my second frame and then back it erases the information. It also will not pass any variables to the second frame. The only way to see the variables after going back to the first frame is to reload the whole SWF. I'm pretty much stuck at this point trying to make the variables persistent through all frames.
this is my code:
package {
import flash.display.MovieClip;
import flash.events.*;
import flash.net.*;
import flash.display.Stage;
public class Main extends MovieClip
{
public function Main() {
var request:URLRequest = new URLRequest("http://localhost/mytest2/dataLayer.php");
request.method = URLRequestMethod.GET;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.load(request);
function completeHandler(evt:Event) {
var username = evt.target.data.username;
var pclass = evt.target.data.pclass;
var hpoints = evt.target.data.hpoints;
var spoints = evt.target.data.spoints;
username_txt.text = username;
class_txt.text = pclass;
hpoints_txt.text = hpoints;
spoints_txt.text = spoints;
}
}
}
}
© Stack Overflow or respective owner