PDA

View Full Version : Flash + PHP LoadVars Array



nixon
December 17th, 2004, 11:18 AM
Hi everyone one..I'm stuck. I want to load headlines that are linked to URL(s) into my flash movie where the dynamic txt box(tickertxt) is here:

_root.scroll.scrollbox.tickertxt

I am working along with my programmer and he built php page that says:

num=1&url1=ticker.php%3Fid%3D1&headline1=Test


here is my actionscript. I cannot get it work:


newsItems=new Array();
myVars = new LoadVars();
myVars.load("ticker.php?flash");
function () {
for (x=1; x<total;x++){
newsItems[x]=new Array();
var what="url"+x;
newsItems[x][0]=myVars.what;
what="headline"+x;
newsItems[x][0]=myVars.what;
}
for(x=1;x<total;x++){
newsItems[x][1]+"<a href=\""+newsItems[x][0]+ "\">Click here for more</a>";
}
}

What is wrong?? Flash shows no errors. Frustrated.

Any help??

icio
December 17th, 2004, 11:59 AM
newsItems = new Array();
myVars = new LoadVars();
myVars.onLoad = function() {
for (x=1; x<total; x++) {
newsItems[x] = new Array();
var what = "url"+x;
newsItems[x][0] = myVars.what;
what = "headline"+x;
newsItems[x][0] = myVars.what;
}
for (x=1; x<total; x++) {
newsItems[x][1]+"<a href=\""+newsItems[x][0]+"\">Click here for more</a>";
}
};
myVars.load("ticker.php?flash");

you never defined that function as the onLoad event handler, and you shouldn't load the file before you specify it, just in case flash loads the file before it specifys the event as that function :)

hope this helps :thumb:

nixon
December 17th, 2004, 02:58 PM
I tried another approach...still no dice. See below.


newsItems = new Array();
myVars = new LoadVars();
myVars.load("ticker.php?flash");
myVars.onLoad = function(success) {
if (success) {
trace("loaded php");
}
else{
trace("no dice!");
}
for (x=1; x<total; x++) {
newsItems[x] = new Array();
var what = "url"+x;
newsItems[x][0] = myVars.what;
what = "headline"+x;
newsItems[x][0] = myVars.what;
}
for (x=1; x<total; x++) {
_root.scroll.scrollbox.tickertxt.htmlText += newsItems[x][1]+"<a href=\""+newsItems[x][0]+"\">Click here for more</a>";
}
};



Any thoughts?? I'm still not getting any flash errors other than the missing php file. I'm lost. I thought it was pretty simple to do:

a simple headline referencing an php page from a db. I guess I was wrong.

Any help would be awesome. This was supposed to be done 2 days ago. :|