Basically what I’m doing is pulling information from a MySQL database and putting into a string and then loading that information into Flash using LoadVars. I’ve used this tutorial to get me off the ground.
All should be well and good from there, I think. There are four separate things for each entry’s information: ID, title, content, and date.
Here is the Actionscript code that loads it and displays it:
#include "textformat.as"
_root.site.createEmptyMovieClip("blogPage", 2);
loadEntries = new LoadVars();
loadEntries.load("http://localhost/fblog/posts.php");
loadEntries.onLoad = function() {
myIDs = new Array();
myTitles = new Array();
myDates = new Array();
myContent = new Array();
for (var a in this) {
//this is where the magic needs to happen
//but I have no idea what to do!
if (a != "onLoad") {
myIDs.push(this[a]);
trace(myIDs);
}
}
var e:Number = 0;
for (e=0;e<myIDs.length;e++) {
_root.site.blogPage.attachMovie("entry", "entry"+e, 50+e);
_root.site.blogPage["entry"+e]._y = 150*e;
_root.site.blogPage["entry"+e].dateText.text = myDates[e];
_root.site.blogPage["entry"+e].contentText.text = myContent[e];
_root.site.blogPage["entry"+e].titleText.text = myTitles[e];
_root.site.blogPage["entry"+e].idText.text = myIDs[e];
}
};
It’s very primitive at the moment.
Here’s my problem, I have no idea how to pull apart the string to get the right information in the right spots.
What I want to do is split the string into it’s elements (ie. id0, title0, date0, content0, id1, etc.) and once I’ve accomplished that, I want to sort out each ID into an array called myIDs, and each title into an array called myTitles, etc.
It’s been a long while since I’ve dealt with actionscript and I’ve never loaded data from a MySQL database for use in Flash before, so any comments are welcome on how to best accomplish this.
Thanks a lot,
Colin
Note to Mods: I put it in this forum because it really has very little to do with PHP and a lot to do with the Actionscript to get this working. If you feel this belongs somewhere better, go ahead and move it.