Passing values from website URL (GET method) to Flash
There are plenty of situations when you may need to pass arguments from URL to the Flash. In my case I was looking for a way to change the Flash banner on a corporate website to display different content for different marketing campaigns. Company runs number of different campaigns for different products, publishing many ads on IT portals. The Flash banner on company's website will display a different advert according to the parameter in URL that will be passed from these ads. (like http://company.com/index.php?campaign=5).
I decided that Flash will be embedded in the PHP file. First we need to use PHP to get the GET variable from the URL. We can achieve that reading $_GET['variable_name']. Next, we need to write this to the FlashVars in <embed> and <object>. Then the last step is to retrieve this variable from ActionScript using loaderInfo.parameters.variable_name.
There are three places to add a variable in the HTML generated from Flash (and renamed to PHP) when publish from Flash to HTML. First search for the JavaScript:
1 |
<script language="JavaScript" type="text/javascript"> |
Next add a tag between the <noscript> tags:
1 |
noscript> |
And in the same object, to the <embed> tag.
1 |
<embed src="banner.swf" FlashVars="<?php echo "name=".$_GET['mymessage'];?>"
|
Below is an ActionScript code to get FlashVars. There is a dynamic text field created on the stage called myDisplay.
1 |
import flash.display.MovieClip; |
Link

