Flash Randomize Images
- Started
- Last post
- 15 Responses
- phirschybar
OK, I know Actionscript and PHP>MySQL both very well. My question is this: I want 5 of the SAME .SWFs on the same page but I want them to display DIFFERENT images whose URLs are pulled from the DB. If I pull the URLs from the DB with PHP in one shot, how do I simply pass them each to my 5 .SWFs?? In other words, how do you pass external parameters to Flash from your HOST HTML or PHP file?
Example: http://www.toothandnail.com/main…
thanks :)
- unfittoprint0
myVars = new LoadVars();
myVars.onLoad = function(sucess){
if (sucess){
for (i=0; i<imageNumber; i++){
this["image"+i].loadMovie(this...
};
} else {
trace ("error!!");
};
}myVars.load("query.php");
stop();
- unfittoprint0
hmm QBN doesn't love 'less than' tags...
_rEPosT:
myVars = new LoadVars();
myVars.onLoad = function(sucess){
if (sucess){
for (i=0; i 'less than' imageNumber; i++){
this["image"+i].loadMovie
(this["image"+i+"URL"]);
};
} else {
trace ("error!!");
};
}myVars.load("query.php");
stop();
- phirschybar0
Thanks UNFIT, only problem is that I dont want each .SWF to have to run the PHP file. I only want to query the DB once so I get a random set of unrepeating image URLS. If I get 5 unique URLs from my query, how can I pass them to the 5 .SWFs??
- unfittoprint0
but that's it: the query will retrieve 5 variables [image1URL, image2URL, etc...]. The loop will pass those variables to each image [by 'evaling' "image"+i+"URL"]...
- mr_flaco0
Cant you just run the query in the php file that prints out your embed tags - then print them with query strings attached to the end of the swf -
file.swf?img1=fileLocation
- phirschybar0
If each .SWF calls the query.php file, then we'll end up with 5 queries and this might result in a repeating image. Am I missing something?
- phirschybar0
FLACO, thats the kind of solution I am looking for but is this possible with flash. Is this how you pass variables to flash?
- phirschybar0
or do you use the tag?
- phirschybar0
... sorry that was PARAM tag.
- unfittoprint0
hmm. I tought you wanted 5 different IMAGES in 1 SWF... my bad.
Then use mr_falco idea. 'Print' the url location on the swf source in the HTML...
- mr_flaco0
its been a while but I know I used to do that when I was working in Flash 4. Im not sure what the code was inside Flash - there might not have abeen any. Do a test...
- phirschybar0
I'm pretty sure that:
movie.swf?img=something
is not valid for passing variables to flash. Anyone know the best method? Does it have to be javascript?
- mr_flaco0
it does work.
- phirschybar0
thanks UNFIT & FLACO!! That link above is the answer.
Peace.