Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Data Integration / April 2008



Tip: Looking for answers? Try searching our database.

Transfer data from Flash AS 3 to PHP

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
lukegatos - 14 Apr 2008 20:00 GMT
I have coded a program to accept several text fields in Flash and then transfer
them (using a defined Class function, sendExample with sendPhp) and display
them with a pfp form. When I run the swf from my pc it transfers the data
correctly (the php file is on my hosted server.) However when I transfer the
swf to the server (along with the class I defined to do the transfer), the php
file is called but no data is transfered. What is missing from the server to
make the data transfer complete? No errors, just a php page with no data
inserted.

import flash.display.Sprite;
    import flash.text.TextField;
    import flash.events.*

    import flash.net.*;       
    import flash.net.URLVariables;

       
     var sendPhp:sendExample = new sendExample();
   

   
    function sendToPhp(evt:MouseEvent):void {
           
        var formUrl:String = "http://'mydomain'/message_form.php"
       
        var formData:URLVariables = new URLVariables();
       
        formData.message1= this.message1.text;
        formData.message2= this.message2.text;
        formData.message3= this.message3.text;
        formData.message4= this.message4.text;
        formData.message5= this.message5.text;
       
        formData.remoteSystem = this.remoteSystem.selectedItem;

   
        sendPhp.submitData(formUrl, formData);

       
    }
       
        submit_btn.addEventListener(MouseEvent.CLICK, sendToPhp, false, 0, true);
   
********************************************
//class definition sendExample

package {
   
   
    import flash.display.MovieClip;
    import flash.text.TextField;
    import flash.events.*;

    import flash.net.*;

       
    public class sendExample extends MovieClip {

    public function sendExample() {}
   
    public function submitData(url:String, _vars:URLVariables):void {

        var request:URLRequest = new URLRequest(url);

       
       
        var loader:URLLoader = new URLLoader();
        loader.dataFormat = URLLoaderDataFormat.VARIABLES;
        request.data = _vars;

        request.method = URLRequestMethod.POST;
        loader.addEventListener(Event.COMPLETE, handleComplete);
        loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
        loader.load(request);
        navigateToURL(request);
        }
       
    private function handleComplete(event:Event):void {
        var loader:URLLoader = URLLoader(event.target);
       
        trace("Par: " + loader.data.par);
        trace("Message: " + loader.data.msg);
        }
       
    private function onIOError(event:IOErrorEvent):void {
        trace("Error loading URL");
        }

   

    }

}
lukegatos - 15 Apr 2008 23:55 GMT
Another detail about the problem - the php page only works correctly when I run
the Flash movie using the Flash CS3 Application program (ctl + Enter). When I
just open the Flash movie using a browser, the php page is called but again no
data is transferred to the form.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.