[MX] Sending variables from PHP to Flash

I’ll try to explain this as best as I can.
I have about 30 .jpg files, 1 .swf file and 1 .php file.
I want the PHP to load multiple copies of the SWF and have each copy load a diffrent JPG. I hope that makes sense. please try to steer me in the right direction. Thanks

Don’t need php for that, simply embed the same empty swf 30 times, in the swf, have o loadMovie(jpgName add “.jpg”), and in the embed tags, use flashvars to set the jpgName variable to the jpg file you want (without the extension).
(or use embed source=holder.swf?jpgName=first / second / etc…)

*Originally posted by eyezberg *
**…and in the embed tags, use flashvars to set the jpgName variable to the jpg file you want (without the extension).
(or use embed source=holder.swf?jpgName=first / second / etc…) **

Ok, I’ve tried both ways and neither work right. They pass the variable correctly but when I try to use loadMovie to load that jpg, it doesnt work.

Heres the code I have:

loadMovie(jpgName+“.jpg”,1);

Like I said, the variable is passed to the swf, it lets me display the variable with a dynamic text box but it doesn’t work with my code.

Any ideas?

http://www.kirupaforum.com/forums/showthread.php?s=&threadid=17037

in this xample, each link, wich is the same .swf… will highlight a different button…

im sure you can translate that to an .jpg being loaded

and what eyezberg tries to tell you here DOZ work, but he forgot to tell you to make the jpgName a _global variable…

its all xplained on that link

Hrm. I downloaded your example and that works but when I try to use it with loadMovie, it doesnt work some how. maybe its the way I’m using load movie. Any ideas?

did you made your var global ?

Yup, heres the Actionscript code:

_global.page=“index”;
loadMovie(page+".swf",1);

and heres the html code:


<EMBED src="highlight.swf" flashVars="page=contact" WIDTH="550" HEIGHT="400"></EMBED>

This dosen’t wor either:

<EMBED src="highlight.swf?page=contact" WIDTH="550" HEIGHT="400"></EMBED>

_global.page=“index”;
loadMovie(page+".swf",1);

needs to be

_global.page=“index”;
loadMovie(_global.page+".swf",1);

edit: your movies wont load…

i edited his post. He was just trying to show the code…

Still not working. :frowning:

I have a dynamic text box, fir the var of it, i put “page” and when I pass the page variable, it gets correctly displayed in the text box but the loadMovie() still doesnt work.

Im trying to pass the word “contact” but that doesnt work but when i hard code it to load “contact.swf” that does work:

[AS]loadMovie(“contact.swf”,1);[/AS]
this works

[AS]loadMovie(_global.page+".swf",1);[/AS]
This doesn’t

are you testing it local or on the net ?

coz using these links:

file.swf?page=contact on a local machine, wont work…

I tried testing it from my server but its still not working. Look at this, I ran some tests, maybe it will shed some light on the problem.
[AS]if (page==“contact”)
loadMovie(“contact.swf”,1);
//this works

if (_global.page==“contact”)
loadMovie(“contact.swf”,1);
//this does not work

if (page==“contact”)
loadMovie(page+".swf",1);
//this does not work

loadMovie(page+".swf",1);
//this does not work[/AS]

What I dont understand is this,
when page=="contact"
why doesn’t this work:
loadMovie(page+".swf",1);
while this does:
loadMovie(“contact.swf”,1);

Could there be some invisable charecters, like a line break or a space or som ething that gets passed along with the word “contact”? but if so then why does ***page==“contact”***?
::confused::

Hi,

If loadMovie is looking for a string you could try something like…

newPage = String(page).concat(".swf");
loadMovie(newPage,1);

It may not be combining your variable and string correctly in the pass to the function.

Liz

Hmm. Still no luck.

What do you get if you trace the variable page? I have sometimes had success using eval to get the contents of a variable so take what I had before then do

loadMovie(eval(newPage),1);

may not work, I have used this to get a usable movie clip name out from a variable before.

Liz

Eval doesnt work.

Remember, the point was to be able to pass variables dynamicaly from outside of flash through a web browser. So since trace() wont work outside of flash I cant do it. Any other ideas?

*when you have declared a var as being _global, as in _global.page, you do not need/should not use _global anymore, just the var name will do.
*did you make sure you’re not trying to load progressive jpg’s?
*start simple, make a test swf with a simple loadMovie(“test.jpg”,1); which should work. then try var = “test.jpg” and loadMovie(var,1); then…etc…it should work…

if you use the var inside functions, you do need to put the _global before it…

Ok this is getting weird.

I did what eyezberg said and started over…

[AS]loadMovie(“contact.swf”,1);
//this works

page=“contact.swf”;
loadMovie(page,1);
//this doesn’t[/AS]

:q:

can i c your .fla ? coz this should work…