Flash Advisor logo
:: Desktop Shortcut
:: Flash Help
Advice from Experts

Closed Thread
Results 1 to 2 of 2
  1. #1

    Default Send data from flash to php/javascript or vice versa

    Hi everybody,

    I was wondering if anyone could help me learn wokring with flash, javascript and even php. I would like to be able to send my data from my flash app to a php file or even to javascript to poppulate a html or a text file. And obviously the opposite, sending data from html to flash with the use of javascript and/or php.


    Please please, does anybody can help me find tutorials in order to learn.

    Thanks for any help.

    Jerome

  2. # ADS
    Join Date
    Always
    Posts
    Many
     
  3. #2
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,

    You will need to understand the use of the loadVars class as well as the sendAndLoad methods in Flash. You will probably want to go with PHP as it is a server side language and adept at data transfer.

    The basics...
    Code:
    //create a loadVars object to BOTH send and receive data
    myVars=new LoadVars();
    //create a load check function to tell when the object has   
    //populated withnew data
    myVars.onLoad=function(success){
    if(!success){
    trace("Failed to load!"){
    }else{
    //establish and retrieve data here
    myVariable=this.setVariable;
    }
    }
    }
    Then, from a button event or other....
    Code:
    myButton.onRelease=function(){
    myVars.sendAndLoad("myFile.php", _root.myVars,"POST")
    }
    Writing data to a text file would be done with PHP. Something like...

    PHP code...
    Code:
    <?
    //Register variables sent from the flash movie
    $myFileName=$_POST["myFileName"]; 
    $article=$_POST["article"];
    //open the text file,write the data sent,close the file 
    $fp = fopen ("$myFileName", "w+");
    fwrite($fp,"$article"); 
    fclose($fp); 
    //check success and echo message back to flash
    if ($fp) { 
    echo ("&msg=Save Successful!&name=$name&myTextSave=$myTextSave");   
    } else { 
    echo ("&error=OK&msg=Save unsuccessful!...an error occurred!"); 
    } 
     
    ?>
    Regards
    NTD
    A mind once stretched by a new idea never regains its original dimensions.
    - Oliver Wendell Holmes

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Sponsors
Create Speaking Characters for your website and Flash movies. 15 Day Free Trial