1 Reply Latest reply on Jun 5, 2007 1:11 PM by John Hall

    URLLoader script problem

    John Hall Level 4
      The following script returns a URLEncoded string from a ColdFusion page just fine. However, if I Alert the variable that is returned in the paired values, it's null. Suggestions?

      <mx:Script>
      <![CDATA[
      import flash.display.Sprite;
      import mx.controls.Alert
      import flash.display.Sprite;
      import flash.events.*;
      import flash.net.*

      private var _loginInfo:URLLoader;

      public function creationCompleteHandler():void {
      currentState = 'login';
      }
      private function loginRoutine():void{
      var variables:URLVariables = new URLVariables();
      var uName:String = username.text;
      var pWord:String = password.text;
      variables.username = uName;
      variables.password = pWord;
      var request:URLRequest = new URLRequest();
      request.url = "loginCheck.cfm";
      request.method = URLRequestMethod.POST;
      request.data = variables;
      var loader:URLLoader = new URLLoader();
      loader.dataFormat = URLLoaderDataFormat.VARIABLES;
      loader.addEventListener(Event.COMPLETE, completeHandler);
      try
      {
      loader.load(request);
      }
      catch (error:Error)
      {
      Alert.show("Unable to load URL");
      }
      }
      private function completeHandler(event:Event):void
      {
      // PROBLEM IS HERE. ALWAYS URLENCODED. IF I ALERT
      // (EVENT.TARGET.DATA.RETURNvALUE) IT IS NULL - RETURNVALUE
      // BEING THE VARIABLE RETURNED FROM CF
      Alert.show(event.target.data);
      // Displays encoded paired values
      // there appears to be no decode method that works properly.

      }


      ]]>
      </mx:Script>
        • 1. Re: URLLoader script problem
          John Hall Level 4
          Well, to answer my own question in case someone else runs into this, a colleague told me to be sure to use the following in CF:

          <cfsetting enablecfoutputonly="yes">

          and of course that cleaned up junk characters that were returning back to the Flex object. All is fine now.