Client LoginView your Shopping CartHelp & Frequently Asked QuestionsEmail Us
Home Services Portfolio Rates & Deals Dreamweaver Templates Web Applications Free Tutorials About Us Contact Us
Web Design Guide > Best Web Design Tools | Web Design Ideas | Web Design Tips | Navigation Tips | Fireworks Tips | Rollover Images | Swap Images | CSS Styles Tutorial
Dreamweaver Tips | Dreamweaver Template | Server Side Includes | Dreamweaver Behaviors | Flash Tutorials > Flash Effects | Flash Sound Buttons | Sound On/Off Button
Flash Preloader | Importing External Data | Promotion > SEO Tips | Google Tips & Page Rank | JavaScript > Date Validation | Email Validation | Phone Validation | Tip Boxes

Importing External Data into Flash

Flash Tutorial to obtain data from External Sources

Below is the Tutorial of how Flash obtains data from External sources. You might be wondering how a flash (.SWF) file obtains data from remote files. Flash can obtain external data from:

The values from these files has to be sent in format understandable by Flash. Flash Actionscript has an XML object to obtain data from XML files. The Flash player loads variables and their values from any of the remote file into its memory and then uses them as required.

How does Flash get external values?

Variable-Value Format

  1. Flash needs to receive the variables and values in the format below:
    For a single variable:
  2. variable1=value1

  3. Similarly for multiple variables it needs the same format, but separated by "&" in between them:

    &variable1=value1
    &variable2=value2&variable3=value3&variable4=value

Note: The variable name should be understandable by you as to what it represents and shouldn't include spaces. Spaces should not be present between the '&', the variable name and the '=' sign. The values can have spaces.



A. Loading Variables from External Text File into Flash

  1. Flash can call any remote text file by using a command in the Actions Panel called loadVariables ('Load/Unload Movie' in Flash 5).
  2. Select its 'Load Variables into location' option and give the URL of your file in the URL box provided. The command will now look like:
  3. loadVariables("your_file_URL.txt","");

    Flash - 5
    Load Variables ("your_file_URL.txt","");

  4. The values of the variables can be accessed from Flash with the help of the variable names specified in the external text file into any Dynamic text field in Flash.
  5. Let the variable name of the Dynamic text field in Flash be called as 'dyn_txt'. The value of the variable can be obtained as follows:

    dyn_txt = variable1;

  6. Obtaining variables and their values into the Flash interface from the text file should be done in a special format as mentioned below. This format can be remembered easily as the Variable-Value format

Variable-Value Format (*.txt file)

  1. Flash needs to receive the variables and values in the format below:
    For a single variable:
  2. variable1=value1

  3. Similarly for multiple variables it needs the same format, but separated by "&" in between them:

    &variable1=value1
    &variable2=value2&variable3=value3&variable4=value



B. Loading Variables from ASP/PHP Files into Flash

  1. The ASP page interacts with the Database and gets the required data and sends the retrieved data to Flash. Read more..
  2. Flash can call any remote text file by using a command in the Actions Panel called loadVariables ('Load/Unload Movie').
  3. Select its 'Load Variables into location' option and give the URL of your file in the URL box provided. The command will now look like:
  4. loadVariables("your_file_URL.asp","");
    (or)
    loadVariables("your_file_URL.php","");

    Flash - 5
    Load Variables ("your_file_URL.asp","");
    (or)
    Load Variables ("your_file_URL.php","");

  5. The values of the variables can be accessed from Flash with the help of the variable names specified in the external text file into any Dynamic text field in Flash.

Variable-Value Format (*.asp file)

Flash needs to receive the variables and values in a similar format form the ASP file as shown below:

    response.write "&name=" & fldName & "&email=" & fldEmail & "&mess=" & fldMess & "&date=" & fldDate

Variable-Value Format (*.php file)

Flash needs to receive the variables and values in a similar format form the PHP file as shown below:

    echo "&name=$fldName&email=$fldEmail&mess=$fldMess&date=$fldDate



C. Loading Data from XML Files into Flash

  1. Flash Actionscript object XML can be used to load the XML document returned by the server into Flash.
  2. We first create an instance of the XML object and then load the XML document using the load command as shown below:
  3. getxmldata=new XML();
    getxmldata.load("xmldata.xml","");

  4. Create 4 Dynamic textboxes with variable names - xmldoc, node_name, topic, author and write the following code in the 3rd frame as given below:
  5. if (getxmldata.loaded){
        var p = getxmldata.firstChild;
        xmldoc = getxmldata.childNodes;
        node_name=p.nodeName;
        topic=p.attributes.topic;
        author=p.attributes.author;
    }

  6. The 'loaded' method is used to check for loading of the XML document, if it is loaded the values are retrieved from the XML document through the methods of XML object.
  7. The firstChild method is used to reference the first child of the parent node, nodeName is used to retrieve the name of the XML Node.
  8. The attributes if present, can be displayed using the attributes.attribute_name by specifying each attribute_name. Thus the output can be displayed as shown below: (Click the Load XML Data Button for a Live Demo)

xmldata.xml file

The XML code used in this tutorial is as follows:

    <TUTORIAL TOPIC="Loading XML Data in Flash" AUTHOR="SmartWebby.com" />

Absolutely FREE Web Templates
Check out these quality free web templates and download them without any registration or sign-up!

FREE Web Design Guide
From web design tips & ideas to HTML, CSS Styles, Fireworks & Dreamweaver you'll find all you need to know about effective web site design right here!

Quality Dreamweaver Templates
Professional quality dreamweaver templates in over 20 categories, starting at just $9.95! Instant download & easy customization

Services > Rapid Web Design | Professional Logo Design | ASP.net, ASP & PHP Programming | Flash Animation & Programming | Reliable Web Hosting | Website Maintenance
Portfolio > Web Design Portfolio | Web Programming Portfolio | Print & Logo Design Portfolio | Flash Animation Portfolio | Outsource Clients Portfolio | Client Testimonials
Rates & Deals > Web Design Rates | Custom Web Design Pricing | Logo Design Pricing | Business Card & Letterhead Pricing | Web Hosting Plans | Website Maintenance Plans