8 Replies Latest reply: Sep 24, 2011 11:29 AM by Ned Murphy RSS

    cannot pass variables from PHP to actionscript 3.0

    rickli0911

      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?