A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Issue when calling a remote PHP file from Flash

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    2

    Issue when calling a remote PHP file from Flash

    Hi all.

    I've run into a problem that's throwing me for a loop and I'm hoping someone can offer some insight. I'm creating a Mac/Win projector using Flash which is supposed to retrieve data from a database by calling a PHP file and returning data. Locally this works exactly as it should. However, when I attempt to call the php file from a remote location, it's not returning any data when the Event.Complete event listener fires. Since it works locally and not remotely, I'm thinking it's firing before the data has been received, but if that's the case I don't know how to fix it. Any help would be great.

    Here's a snippet of the relevant code:

    Code:
    	var phpLoader:URLLoader = new URLLoader();
    	var phpVars:URLVariables = new URLVariables("return=true");
    	var phpRequest:URLRequest = new URLRequest("http://..somefile.php");
    	phpRequest.method = "post";
    	phpRequest.data = phpVars;
    	phpLoader.dataFormat = "variables";
    	phpLoader.addEventListener(Event.COMPLETE, onReturn);
    				
    	phpLoader.load(phpRequest);
    				
    	function onReturn(e:Event):void{
    		trace("data: "+e.currentTarget.data); //Returns = "data:"
            }

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Try
    PHP Code:
    phpLoader.dataFormat URLLoaderDataFormat.TEXT
    It works with my testing here, using exe projector.

    If you have major problems then you will need to attach your files.
    Last edited by fruitbeard; 07-30-2015 at 01:28 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center