Skip navigation
rickli0911
Currently Being Moderated

cannot pass variables from PHP to actionscript 3.0

Sep 24, 2011 3:36 AM

I am using CS3 and I write the following code as to pass variable to flash from PHP

 

 

Actionscript

 

 

var myLoader:URLLoader = new URLLoader();

myLoader.dataFormat = URLLoaderDataFormat.TEXT;

var myRequest:URLRequest=new URLRequest("http://localhost/moodle/value.php");

myLoader.load(myRequest);

myLoader.addEventListener(Event.COMPLETE,onCompleteHandler);

 

 

var myValue: String;

function onCompleteHandler(e:Event):void{

          var myvariable: URLVariables = new URLVariables(e.target.data);

          myValue = myvariable.values;

                  trace(myValue);

}

 

 

 

 

PHP file

 

 

<?php

   echo ('values = 8');

?>

 

 

 

 

But I always get the error and cannot get the values by using trace();

Before i try to use "myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;" I still get the same error.

Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs

          at Error$/throwError()

          at flash.net::URLVariables/decode()

          at flash.net::URLVariables$iinit()

          at flash.net::URLLoader/flash.net:URLLoader::onComplete()

 

 

Can anyone help me?

 
Replies
  • Currently Being Moderated
    Sep 24, 2011 5:59 AM   in reply to rickli0911

    Rewrite your PHP...

     

    <?php

       echo "values=8";

    ?>

     

    edited: removed info regarding different posting

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 24, 2011 6:48 AM   in reply to rickli0911

    Have you tried tracing e.target.data?

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 24, 2011 7:22 AM   in reply to rickli0911

    As I showed earlier, remove the spaces around the = ...  "values=8"

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 24, 2011 11:29 AM   in reply to rickli0911

    You're welcome

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points