Categories

Partners
  • Website Templates

  • Design Feeds

  • Adobe Photoshop Tutorials

  • Website Templates, WordPress Themes

  • Website Templates

  • Flash Web Sites

  • Photoshop Templates

  • Photo Contests

  • Photo Tips
  • Search


    Advanced Search


    Partner Links
  • Adobe Photoshop Tutorials

  • Free Stock Photos and Images



  • Website Templates

    Using LoadVars.send Method to Exchange Data with a Server-Side Script
    Published  06/19/2006 | Macromedia Flash
       




    Using LoadVars.send Method to Exchange Data
    with a Server-Side Script

    If you want to send variables from Flash to a server-side script (such as ColdFusion, PHP, ASP, etc.) you can use the LoadVars class' send method. The code below creates a new LoadVars instance, adds a few values to the LoadVars object and then sends the variables to a script called inserthighscore.cfm as Form variables (using the POST method). If you wanted to send the variables as URL variables instead, you would need to simply change the POST to a GET. The one important thing about using LoadVars.send is that a new browser window is generally launched. If you don't want a new browser window to necessarily open each time the person receives a high score, you may wan tto use the LoadVars class' sendAndLoad method instead.

    1. var myLoadVars_lv:LoadVars = new LoadVars();
    2. // create some variables in the LoadVars instance.
    3. myLoadVars.timestamp = new Date();
    4. myLoadVars.name = name_txt.text;
    5. myLoadVars.score = score_txt.text;
    6. // send variables in the LoadVars object to the server-side script.
    7. /* Flash will send these variables to the specified page using the method, in this case POST, and launch a new window which will display the results. */
    8. myLoadVars.send("inserthighscore.cfm", "_blank", "POST");
    Article Series
    This article is part 10 of a 13 part series. Other articles in this series are shown below:
    1. Flash FAQ - Introduction
    2. Streaming FLV files in Flash MX 2004
    3. Creating an XML Packet with Flash - the easy way
    4. Creating an XML Packet with Flash - the hard way
    5. Getting more colors for your Halo
    6. Loading in Images Using the MovieClipLoader Class
    7. Parsing an XML Packet in Flash
    8. Parsing XML in Flash Using the XMLConnector
    9. Sending an XML Packet to a Server-Side Page
    10. Using LoadVars.send Method to Exchange Data with a Server-Side Script
    11. Using the Alert component
    12. Using the LoadVars Class to Load Variables
    13. Using XPath in Flash MX 2004