Create Dynamic XML - Flash communication (working)

Hey everyone!

Ever wanted flash to be able to load info from external files(such as xml) as soon as these files were updated?

–updated–problem solved using Method 2 discussed below-- 31 July

Two ways that i know how to do this
Method 1-

use a timer so that flash will load the xml file every second or so then load it if a value in the xml is different that the stored value.

This is how i did it:

  1. Use a timer to reload the xml file every 1 second.
    This causes problems with constantly loading images every one second – (bad).
  2. Use a timer but write a script to check if xml is new - if new, load it,
    otherwise dont.

Checking if XML is new or old:
php creates xml with time of creation node using the time() function “<time>1217229719</time>”
When flash loads an xml it stores the time value in variable “time_xml”. Every 1 second it loads a new xml in a tempory loader and compares the <time> value in this loader with the one stored in “time_xml”. If they are different, it loads the temp data into flash and sets the time_xml to the new <time>, otherwise it does nothing.

This creates real time flash - XML updating but it is very taxing on the flash application, making sluggish.

Here is file:
Read the fla comments to get it to work on server
2 files, unrar and copy the fla into the folder “flash xml”

files too big, download from:

Method 2 -

Since javascript can communicate with flash, use php to tell javascript when php creates the xml, then javascript will tell flash to load the file. (best solution)

This is an excellent tutorial showing how this is done.

Link
http://kb.adobe.com/selfservice/view…nalId=tn_15683

google cached link
http://209.85.141.104/search?q=cache…ient=firefox-a