AS3 PHP and MYSQL

By AndrewPSW | Jul 9, 2009

actionscript3

hello i am really stumped on this on hopefully someone can help.

I have a PHP file that is pulling data from a MYSQL database and outputting the variables as you see below. The variable "monNum=3" is displaying the number of results found. I want to use this data to create a forloop in flash the monNum=3 would represent the length of the loop in flash and i want the data in the monster#= to populate as a list. It works now if i specify the variable name but i would like a way to make this work on a loop because i want to give the user fredom to add as many name as they would like.

PHP Code:


begin=var&monNum=3&monster0=sparky&monster1=joe&monster2=john&finalResult=done 




ActionScript Code:
var monsterTxt:TextField = new TextField; addChild(monsterTxt); var builtLoader:URLLoader = new URLLoader; var builtReq:URLRequest = new URLRequest(“php/prebuilt.php”); builtLoader.addEventListener(Event.COMPLETE, monstersLoaded); builtLoader.load(builtReq); function monstersLoaded(event:Event):void {     var builtBack:URLVariables = new URLVariables(builtLoader.data);     builtLoader.dataFormat = URLLoaderDataFormat.TEXT;         var mon:String = new String;     mon = String(builtBack.monster1);// this works but i have to specify the variable name         for(var i = 0; i < 3 ; i++){ //I want the i < 3 to be i < the monNum variable         //trace(mon);         var titles:TextField = new TextField();       titles.width = 100;         titles.selectable = false;      titles.text = mon;         addChild(titles);         titles.y = 20*i;     } }

actionscript3

Please reply at our Forum

Leave a Comment

If you would like to make a comment, please fill out the form below.

Name (required)

Email (required)

Website

Comments

© 2007 ActionScript 3.0