passing php variable to FLASH

this is my php file:

GLObal $test;

$test = "'/Photos/P1010049.jpg'";
echo ("test=" .$test);


this is my flash actionscript:

addressVars = new LoadVars();
addressVars.onLoad = function() {
image0uri = addressVars.test;

the problem is that my flash app does not load the php variable and does not show the image i'm wanting to show. If i replace the last line of the action script with:
image0uri =  '/Photos/P1010049.jpg';

it works perfectly.

Any ideas?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I don't know squat about flash, but is there a way to echo out variables to see what's set to?

Like an echo image0uri or something, so you can see what it is actually set to? It might help to know if it's blank, or set to some weird unexpected path.
Not too familiar with flash, but if that file with the actionscript in it can be parsed with PHP, then you can simply output the variable directly into the script.  Otherwise, here are some links I found: - EE flash area - article on passing variables into flash via html.  output the php variable right onto the page that the user is viewing

you can pass a vaariable to flash using get


$myvariable = "testvariable stuff here";
<object width="550" height="400">
<param name="movie" value="somefilename.swf">
<embed src="somefilename.swf?myvariable=<?php echo $myvariable; ?>" width="550" height="400">
then the variable is passed to the swf file when it is called.
then you can use the variable myvariable or whatever text is in between the ? and = in the url to the flash file.

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

$test = urlencode("'/Photos/P1010049.jpg'");
echo ("&test=" .$test);

Always you need to print the variables with vlaues as query string. Only pre-caution has to be taken is that we need to start the output with "&" so that it adds these variable to the Loadvars object you create in the flash.

For example :

print "&var1=value1&var2=value2";

Suppose you want to post some values to the php script and get the details back, then its better to use

LoadVars.sendAndLoad method.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
michaelbrewittAuthor Commented:
tolgoang - that didn't work.

Anyone else, any more suggestions?

Did you try my idea??


PS: I use it on a lot of Flash applications that I have.
In this contrived example, suppose that you have a Flash movie that loads an image file and display the image (using  loadMovie on Flash MX - if you're using Flash 5, think of it as loading another .swf file).  

You want to be able to use the same swf file on many pages to show different images.  Obviously, you need to pass the image filename to Flash.  What can you do?  Since a filename is such a simple text, you can use query string to pass it.  

Assuming the image filename is image1.jpg, located at a folder named images.  And assuming that the Flash movie will use a variable named imageFilename to refer to the file, then we can do this:

<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
  WIDTH="250" HEIGHT="300" id="flaMovie1">
  <PARAM NAME=movie VALUE="flaMovie1.swf?imageFilename=images%2Fimage1%2Ejpg">
  <PARAM NAME=quality VALUE=high>
  <EMBED src="flaMovie1.swf?imageFilename=images%2Fimage1%2Ejpg"
    quality=high bgcolor=#FFFFFF WIDTH="250" HEIGHT="250" NAME="flaMovie1"

There you see that I appended a query string after the Flash movie filename (flaMovie1.swf).  The query string contains one variable: imageFilename, with the value of images/image1.jpg.  

Note: The %2F is the url encoding for the "/" sign, and %2E is the url encoding for the "." sign.  Since these symbols are unsafe or reserved, we should url encode them, although at the present Flash does not seem to care.  So saying: imageFilename=images%2Fimage1%2Ejpg is essentially the same as saying imageFilename=images/image1.jpg.
I found that after searching google and I tested it and that example works.

this page has a sorts of methods:

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.