+ Reply to Thread
Results 1 to 3 of 3

Thread: Example Send and Get Data from PHP in Flash.

  1. #1
    satheesh's Avatar
    satheesh is offline x10 Elder satheesh is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Tamil Nadu,India
    Posts
    883

    Smile Example Send and Get Data from PHP in Flash.

    Example Send and Get Data from PHP in Flash


    1.Create a blank document.
    2.Create a Input Text field and Set them ins="msg".
    3.Place your button on the stage.
    4.Select the button and press F9.
    Copy code below and paste it.


    Code:
    on (press) {
        var send_msg:LoadVars = new LoadVars();
        send_msg.flash = true;
        send_msg.msg = msg.text;
        msg.text = "Sending please wait...";
        send_msg.sendAndLoad("index.php", send_msg, "POST");
        send_msg.onLoad = function() {
            if (send_msg.sta == "true") {
                msg.text = "Now refresh your Page";
            } else {
                msg.text = "Failed";
            }
        };
    }

    5.Save and publish it(File name="Data").
    6.Create a new php called "index.php".
    7.Copy the code below and paste it.

    PHP Code:
    <?php
    //Get a Msg from Flash
    $flash=$_POST['flash'];
    $msg=$_POST['msg'];

    if(
    $flash=='true')
    {
        
    //Open a File
        
    $open=fopen("msg.txt",'w');

        
    //Write to file
        
    $write=fwrite($open,$msg);
        if(
    $write)
        {
             print 
    "&sta=true&";
        }
        
        
    }
    else
    {
         print
    '  <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="550" height="100" id="Data" align="middle">
        <param name="allowScriptAccess" value="sameDomain" />
        <param name="movie" value="Data.swf" />
        <param name="quality" value="high" />
        <param name="bgcolor" value="#ffffff" />
        <embed src="Data.swf" quality="high" bgcolor="#ffffff" width="550" height="100" name="Data" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
      </object>
      <p>Type your text in the text field </p>'
    ;
        
    //Open a File
        
    $open=fopen("msg.txt",'r+');

        
    //Read a file
        
    $read=fread($open,1024);

        
    //Print as HTML
        
    print "<br><b><i>Your Previous Sended Msg is: $read <br><font color=\"#FF0000\"> By Satheesh KUmar</font></i></b>";
    }
    ?>
    Save and Run.



    Demo:http://www.svprm.x10hosting.com/for_.../php/index.php
    I want to buy Some Scripts So Please Click This link:http://affiliate.tufat.com/index.php?id=4384
    Please rate my site:Click here




  2. #2
    Jesse's Avatar
    Jesse is offline Lord Of The Keys Jesse is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    Manila, PH
    Posts
    1,357

    Re: Example Send and Get Data from PHP in Flash.

    Nice Tutorial
    x10HOSTING
    Member Since October 2007.

    JESSEMAN.ME
    | iMusicz.net

  3. #3
    satheesh's Avatar
    satheesh is offline x10 Elder satheesh is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Tamil Nadu,India
    Posts
    883

    Re: Example Send and Get Data from PHP in Flash.

    Thanks,If you like my tutorial Click on the for my reputation
    Edit:
    Please rate this Thread.
    Last edited by satheesh; 12-22-2007 at 09:10 AM. Reason: Automerged Doublepost
    I want to buy Some Scripts So Please Click This link:http://affiliate.tufat.com/index.php?id=4384
    Please rate my site:Click here




+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers