PDA

View Full Version : PHP and flash - not working..?



jerry
October 4th, 2005, 02:54 PM
Hey there! :)

I'm playing around with PHP and flash at the moment. And this is perhaps a silly question, but i'm trying to display 'a part of the url' in my flash movie (in a dynamic textfield).
It's a rather simple setup, I've got my flash movie and two PHP documents (myMovie.php and test.php) - in my flash movie I've got a button and a dynamic textfield (with a var name of 'cake').
The following action is assigned to the button:

on (release) {
loadVariablesNum ("test.php", "0", "Post");
}


The test.php looks like this:

<?php

include "MyTest.php";

print "_root.cake=$showit";

?>

myMovie.php contains my flash movie and the following PHP code:

<?php
$showit = $id;
?>

The idea is, that when typing the URL like this: myMovie.php?id=hello, and then pressing the button, the textfield should show 'hallo' - BUT, it's not working, and it's probably because I don't know enough about PHP (and flash for that matter..) :(

Could someone please point me in the right direction - any help would be nice.. :)

Bill H.
October 4th, 2005, 05:09 PM
Hi,
This tech note from macromedia should give you the low-down on passing variables to flash from the html in which it is embedded:
http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_14253#querystring

With that in mind, you can use php's $_GET[] to get the variables from the url.

Like this:

<?php
if($_GET['id']) {
$id = $_GET['id'];
}
?>

Then of course you will want to replace the parameter to be passed into flash with <?php echo $id; ?>

Also if you use UFO or flashObject to embed your flash, they also support the passing of parameters to your movie.

Hope that helps.

jerry
October 4th, 2005, 05:14 PM
Thanks alot Bill - I'll give it a try.. :)

jerry
October 4th, 2005, 05:24 PM
hmmm.. it seems I get a parse error when using:
<?php
if($_GET['id']) {
$id = $_GET['id'];
}
?>

unexpected '}' :(

jerry
October 4th, 2005, 05:55 PM
..well, nevermind - I got it working with the tech note from macromedia.. Again, THX :)