I would like to be able to dynamically populate a dynamic text field (assuming that's the best component to use) with an array of data from PHP. I have attached my PHP code and my Flash Code. The PHP code is working fine and generating the array. The first part of the AS code is working as I can see the pop-up window with the PHP array in it. However, I can't figure out how to get the array to display in the dynamic text box. I have created a dynamic text box in flash with nothing in the 'instance name' box and 'events' in the var box. What am I missing? Any help would be greatly appreciated!!! PHP CODE: $eventsQuery = "SELECT * FROM events_tb ORDER BY eventID DESC LIMIT 5"; $eventsResult = mysql_query($eventsQuery); $i= 0; while ($eventsRow = mysql_fetch_array($eventsResult)) { echo "event$i=<a href='content.php?fcn=events&pieceid=".$eventsRow['eventID']."'>".$eventsRow['ev entName']."</a>,"; $i++; } AS CODE: myData = new LoadVars() myData.ref = this myData.load("flIndexEvents.php") getURL("flIndexEvents.php", "_new") myData.onLoad = function(succes){ if(succes){ for(var i=0; i<this.events; i++){ this.ref["events"+i].text = this["events"+i] } } else trace("Error loading data") }
1. The TextField needs to have the html property true. 2. You need to use the htmlText property to add the html incoming. You need to send the total number of items along with each item. Then create a loop in the onLoad method. Something along these lines. for (var i:Number = 0; i < this.totalItems; i++ { my_txt.htmlText += this["event" + i] + "<br>"; } You also can consider sending the PHP data as one variable with a delimiter like a double bar || and using split myItems = this.thePhpVar.split("||"); // myItems is an array Thus you do not need to have PHP to send the count and one less fault opening.
Don't see what you're looking for? Try a search.
|