michaelbrewitt
asked on
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.load("http://www.zzzzzzzzzzzzzz/flash/test.php");
addressVars.onLoad = function() {
trace(addressVars.test);
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?
<?
GLObal $test;
$test = "'/Photos/P1010049.jpg'";
echo ("test=" .$test);
?>
this is my flash actionscript:
addressVars = new LoadVars();
addressVars.load("http://www.zzzzzzzzzzzzzz/flash/test.php");
addressVars.onLoad = function() {
trace(addressVars.test);
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?
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:
https://www.experts-exchange.com/Web/WebDevSoftware/Flash/ - EE flash area
http://flashmx2004.com/forums/index.php?showtopic=1351 - article on passing variables into flash via html. output the php variable right onto the page that the user is viewing
-Matt
https://www.experts-exchange.com/Web/WebDevSoftware/Flash/ - EE flash area
http://flashmx2004.com/forums/index.php?showtopic=1351 - article on passing variables into flash via html. output the php variable right onto the page that the user is viewing
-Matt
you can pass a vaariable to flash using get
example
--------------------------
<?php
$myvariable = "testvariable stuff here";
?>
<object width="550" height="400">
<param name="movie" value="somefilename.swf">
<embed src="somefilename.swf?myva riable=<?p hp echo $myvariable; ?>" width="550" height="400">
</embed>
</object>
--------------------------
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.
Max
example
--------------------------
<?php
$myvariable = "testvariable stuff here";
?>
<object width="550" height="400">
<param name="movie" value="somefilename.swf">
<embed src="somefilename.swf?myva
</embed>
</object>
--------------------------
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.
Max
$test = urlencode("'/Photos/P10100 49.jpg'");
echo ("&test=" .$test);
echo ("&test=" .$test);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
tolgoang - that didn't work.
Anyone else, any more suggestions?
Thanks
Anyone else, any more suggestions?
Thanks
Did you try my idea??
Max
PS: I use it on a lot of Flash applications that I have.
Max
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-AE 6D-11cf-96 B8-4445535 40000"
codebase="http://download.macromedia.com/"
WIDTH="250" HEIGHT="300" id="flaMovie1">
<PARAM NAME=movie VALUE="flaMovie1.swf?image Filename=i mages%2Fim age1%2Ejpg ">
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src="flaMovie1.swf?imageFi lename=ima ges%2Fimag e1%2Ejpg"
quality=high bgcolor=#FFFFFF WIDTH="250" HEIGHT="250" NAME="flaMovie1"
TYPE="application/x-shockw ave-flash"
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
</EMBED>
</OBJECT>
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%2Fima ge1%2Ejpg is essentially the same as saying imageFilename=images/image 1.jpg.
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-AE
codebase="http://download.macromedia.com/"
WIDTH="250" HEIGHT="300" id="flaMovie1">
<PARAM NAME=movie VALUE="flaMovie1.swf?image
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src="flaMovie1.swf?imageFi
quality=high bgcolor=#FFFFFF WIDTH="250" HEIGHT="250" NAME="flaMovie1"
TYPE="application/x-shockw
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
</EMBED>
</OBJECT>
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%2Fima
I found that after searching google and I tested it and that example works.
Max
Max
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.