The Last File (end.fla)

The final piece of the puzzle is the end.fla and end.php combination. If we assume I originally passed the value "test", by the time I get to the end.php file the URL will be something like:

www.site.com/end.php?value=test

Now we have the value variable inside the end.php page but we need to get it into the Flash file within end.php. Luckily, Macromedia are consistently awesome so they made Flash compatible with the GET variable method. If I have an swf file online (it only works online, not on your hard-drive) called example.swf, and I open it in my browser by typing: example.swf?variable=1234 , Flash recognizes that extra information as a passed variable and creates a variable within the example.swf file called 'variable' which holds the string "1234". So we're going to exploit this feature here.

As most of you would know, when you embed your flash file in an HTML file you use HTML <object> and <embed> tags. Each of these tags makes reference to the swf file you wish to embed, so all you have to do is include the value you wish to pass by adding "?variable=1234". Since we are passing a dynamic variable though, we use dynamic code which looks like this:

<param name=movie value="end.swf?value=<?php echo $value; ?>">
<embed realsrc="end.swf?value=<?php echo $value; ?>" src="http://www.actionscript.org/dev/admin/end.swf?value=<?php echo $value; ?>" quality=high bgcolor=#FFFFFF ...>

Here, as before I have use the PHP code which states "Insert the contents of the value variable here". So if I had passed the value "test" these lines will be processed as:

<param name=movie value="end.swf?value=test">
<embed realsrc="end.swf?value=test" src="http://www.actionscript.org/dev/admin/end.swf?value=test" quality=high bgcolor=#FFFFFF ...>

This code is just like our example.swf example above. The question-mark indicates we're passing a variable, the variable is called 'value' and it's value is "test".. Flash reads all this in and as a result inserts the string "test" in the value text field in end.swf.

I've done my best to explain this one but it gets kind of messy along the way. Checkout these relevant threads on the forums and the source code to become familiar with the method.

http://www.actionscript.org/forums/showthread.php3?threadid=743

http://www.actionscript.org/forums/showthread.php3?threadid=903

If you have more questions, post them on the forums as usual. Cheers.

Jesse Stratford is the Co-Master of ActionScript.org and a freelance Flash developer and teacher. He is based in Australia and enjoys all things Flash.

NB: If you have comments or feedback please feel free to email me, but please do not email me Flash questions; the forums are provided for that purpose and you will get a faster answer by posting you question there.

If you have found this tutorial helpful, I hope that you will take 30 seconds to visit The Hunger Site where, with just one click you can make a free donation of food to a starving person in a third-world country. We do not benefit financially from this action; it is purely an act of charity.
This tutorial is protected by International Intellectual Property Rights laws and may not be reproduced or redistributed in full or part, without the prior written consent of the author. Unauthorized reproduction of this tutorial or its contents may result in prosecution. I've worked hard on this tutorial, please don't steal it.