A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [RESOLVED] Actionscript to php and back (working, but...)

  1. #1
    Senior Member
    Join Date
    Jul 2002
    Location
    Argentina
    Posts
    130

    resolved [RESOLVED] Actionscript to php and back (working, but...)

    Hey guys!
    I have a simple script that sends a variable to php (locally) and then php returns another variable to flash...

    Here's the simple script:

    Code:
    var variables:URLVariables = new URLVariables();
    var varSend:URLRequest = new URLRequest("http://localhost/test/test.php");
    varSend.method = URLRequestMethod.POST;
    varSend.data = variables;
    var varLoader:URLLoader = new URLLoader;
    //varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
    varLoader.dataFormat = URLLoaderDataFormat.TEXT;
    varLoader.addEventListener(Event.COMPLETE, completeHandler);
    
    variables.action = "submitForm";
    varLoader.load(varSend);
    
    function completeHandler(event:Event):void
    {
    	trace("works");
    	trace(event.target.data);
    	var checkStatus:String = event.target.data.imdoneUpdate;
    	trace(checkStatus);
    	if (checkStatus == "1")
    	{
    		trace("WORKS");
    	}
    	else
    	{
    		trace("NEEEEEEH");
    	}
    	
    }
    PHP CODE:
    Code:
    $action=$_POST['action'];
    if ($action == "submitForm")
    {
    	
    	$imdoneUpdate = true;
    	echo "imdoneUpdate=".$imdoneUpdate;
    }
    flash output:
    works
    imdoneUpdate=1
    ReferenceError: Error #1069: Property imdoneUpdate not found on String and there is no default value.
    at test_fla::MainTimeline/completeHandler()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

    As you can see...flash is connecting to php and even the trace for event.target.data is tracing imdoneUpdate=1 ...so why event.target.data.imdoneUpdate is not properly working??
    Am I echoing incorrectly through php?

    Thanks a lot in advance!

  2. #2
    Senior Member
    Join Date
    Jul 2002
    Location
    Argentina
    Posts
    130
    Solved on a different forum, here's the fix:

    Code:
    var varPHP:URLVariables = new URLVariables(event.target.data)
    var checkStatus:String = varPHP.imdoneUpdate;

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