Morning everyone.
I have a flash banner that I’m creating that pulls dynamic content from a database. It’s basically a URLRequest to a PHP file, the PHP file calls the database, returns the values, and brings them into Flash. Using URLVariables, I split it out and put certain values into certain textfields. Pretty basic stuff.
The problem I’m having is this banner runs over and over again (as I want it to). In doing so, it makes the call to the database on each iteration (which I don’t want to). I’m trying to find a way to store the variables I pull in and pass them on. At first I was hoping to just get to the end of the clip and do a gotoAndPlay(2) to get it to loop and not include the database call. However, doing so gives me empty fields. This made me realize that anytime I reference the data after the first frame, I get null results.
Here’s my code snippet:
var req:URLRequest = new URLRequest(theURL);
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onComplete);
loader.load(req);
function onComplete(event:Event):void{
var vars:URLVariables = new URLVariables(event.target.data);
price_mc.price_txt.text = vars.data1;
cb_mc.cb_txt.text = vars.data1;
tcb_mc.tcb_txt.text = vars.data1;
}
Any thoughts on how I can get the dynamic data in these text fields passed on without doing the database call each iteration?
Thanks.