Recently, I found myself in a situation where it was necessary to pass information in the form of GET data from a simple flash button to a server side scripting language- all without reloading the current page. A client was running several different flash animated banners ads via XML layer popup, underlining some of her most popular website products and online services. She needed a simple way to track the overall efficiency of her small ad campaign. Specifically, she needed to know which banners were being clicked on and which banners were simply annoying or inconsequential to her client base. She also needed to know which were the most popular browsers accessing these pages.
I’ll try to describe what needed to happen with out getting too techie.
An XML layer popup would pop up, offering the end user with a two options. In Option A, one could click on the cute little popup. This would take them to wherever the popup was designed to take them. Option B was for the end user to close the popup, and that would simply hide the XML layer’s visibility property.
At first, it sounded easy. However, beyond the obvious functionality of options A and B, each option needed to open, write, and save to an external file all without refreshing the current page. After all, the last thing anyone wants to see after closing a popup is another page pop up.
Here’s the solution. I created the following <iframe>.
|<IFRAME id=”ifrMain” name=”main” src=”myscript.php”
frameborder=”0″ width=”0″ height=”0″ scrolling=”no”
Note that the SRC property is the location of our PHP script, which will be summoned later, to write and save to our external file. Notice our width and height properties are both set to zero.
I still submit the data to my PHP script, from within the flash banner popup
with the help of ActionScript’s cool little getURL() function:.
However because the target (main) was loaded inside our little hidden <iframe>, only the <iframe> refreshes. The user will not see a window refresh, the scrip will be parsed by PHP and everyone lived happily ever after.
Adam Fletcher is the webmaster of Hardware Software Articles http://www.hardwaresoftwarearticles.com .