Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

How to get vars from PHP into Flash

Question posted by: jiwas78 (Newbie) on June 15th, 2008 04:20 PM
Hey there guys,
After some research into PHP and Actionscript, I think I have come close to doing what I want to do. Except now I'm stuck.

Here is what I have in my header.php file:

<?php
$c_page = $_SERVER['PHP_SELF'];
$c_page = basename($c_page, ".php");
?>

So I have the current file name of the php page stored in a variable called $c_page. Right?

I want to pass it on to a single Flash file, which looks like this:

<object align="middle">
<param name="quality" value="high" />
<param name="movie" value="swf/index.swf?<? echo "cPage=$c_page"; ?>" />
<embed src="swf/index.swf?<? echo "cPage=$c_page"; ?>" quality="high" width="780" height="440" align="middle"></embed>
</object>

Now I want to dynamically load a different background image depending on which page the swf file is in.

But when I add this:

_root.bgHostAnim_MC.bgHost_MC.loadMovie('../images/'+cPage+'Bg.jpg');

to the parent of the movieclip that I want to load the image into, it won't recognise cPage as a variable and comes back as undefined.

Can anyone help?

Cheers.
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
jiwas78's Avatar
jiwas78
Newbie
6 Posts
June 15th, 2008
04:44 PM
#2

Re: How to get vars from PHP into Flash
Also, in case this helps..

When I go to preview the swf, Flash gives me an error:

Error opening URL 'file:///....images/undefinedBg.jpg'

Which I understand because flash needs to get the data from the php file.

So I then refresh my browser. But the swf still file doesn't find the image.

It's called indexBg.jpg so it should work with the bit of actionscript I have but I still don't get it..

Any help much appreciated

Reply
ssouhrada's Avatar
ssouhrada
Newbie
7 Posts
July 2nd, 2008
07:25 PM
#3

Re: How to get vars from PHP into Flash
Hello,

Passing variables to flash is not too difficult. Based on the code you put up their I think you are just missing a few lines to have it recognize the variable (flashvar). See this link for more information.

http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_16417


Thanks

Reply
jiwas78's Avatar
jiwas78
Newbie
6 Posts
July 5th, 2008
04:54 AM
#4

Re: How to get vars from PHP into Flash
Thanks. But I think I sorted it out by using an absolute path. Like so..

Code: ( text )
  1. _root.bgHostAnim_MC.bgHost_MC.loadMovie("http://localhost/hopscotch/images/"+cPage+"Bg.jpg");


One thing I'm still trying to figure out is how Flash treats relative paths. Are they relative to where the SWF is or relative to where the .php or .html that it's embedded in is.. I've tried both and I still don't know. hmm..

Reply
Reply
Not the answer you were looking for? Post your question . . .
183,940 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top Flash / Actionscript Forum Contributors