6 Replies Latest reply on Oct 29, 2007 6:39 AM by jlmoller

    error 1119 - text not compatable with String?

      I can't figure out how to declare a String variable that gets populated as a result of returned XML without getting an error.

      In my CDATA section:

      public var MACompany:String = new String();

      public function doLoginPage():void {

      // Grab Returned Data (XML structure)
      MACompany.text=loginPage.lastResult.MAData.MAAccount.MACompany; // <-- error 1119

      This is later referred to in the mxml:

      <mx:TextInput width="400" text="{MACompany.text}" />

      Why is this giving me this error - How else would I declare it?

      1119: Access of possibly undefined property text through a reference with static type String.

      (I added the var code as a result of this run time error, which was equally obtuse:

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at SDDS/doLoginPage()
      at SDDS/___Button1_click()
        • 1. Re: error 1119 - text not compatable with String?
          ntsiii Level 3
          First, all data service calls in flex are asynchronous. You CANNOT reference the result in the same function in which you invoke send(). You need to use a result handler function.

          I think the error is misleading. Assign a hard coded string to the text property, I bet that works, assuming MACompany is rendererd and in scope at the time of the assignment.

          Below are some snippets showing how to use HTTPservice to get data.

          Sample code using HTTPService, e4x, handler function to populate a list item.
          Also shows usage of AsyncToken.

          The DataGrid tag:
          <mx:DataGrid id="dg" dataProvider="{_xlcMyListData}" .../>

          The HTTPService tag:
          <mx:HTTPService id="service" resultFormat="e4x" result="onResult(event)" fault="..../>

          Script block declaration:
          import mx.rpc.Events.ResultEvent;
          [Bindable]private var _xlcMyListData:XMLListCollection;

          Invoke send:
          var oRequest:Object = new Object();
          oRequest.Arg1 = "value1";
          var callToken:AsyncToken = service.send(oRequest);
          token.callId = "myQuery1";

          Result Handler function:
          private function onResult(oEvent:ResultEvent):void {
          var xmlResult:XML = XML(event.result); //converts result Object to XML. can also use "as" operator
          var xlMyListData:XMLList = xmlResult.myListData; //depends on xml format, is row data
          _xlcMyListData = new XMLListCollection(xlMyListData); //wrap the XMLList in a collection
          trace(_xlcMyListData.toXMLString()); //so you can see exactly how to specify dataField or build labelFunction
          var callToken:AsyncToken = oEvent.token;
          var sCallId = callToken.callId; //"myQuery1"
          switch(sCallId) { //Process the result conditionally
          case "myQuery1":
          doQuery2(); //do whatever
          • 2. Re: error 1119 - text not compatable with String?
            jlmoller Level 1
            I'm not using a DataGrid - I have found a few examples of DataGrid and dataProvider; from what I can tell, I don't want to use that methodology .

            The variables that are being returned from the PHP call will be scattered among various Canvas sceens (when you log in, the data returned fills in a lot of fields that you can later alter if you want to). This is why I was setting them specifically to the field name I wanted to fill In (there are actually about 20 fields all together, and will probably have more as the application evolves).

            As it is. I will also be sending/receiving all data in Base 64 (I did figure out how to used the built in encoder/decoder) and have gotten at least the send to the PHP app to work correctly.

            I'll try to pick out the pieces of your example that apply.

            I wish there was documentation more related to how to do things than just a defintion of what things do (I lke the php.net web site - lots of contributed examples that solve real problems; The Adobe Flex documentation examples seem to be buggy at best) - its really hard to guess what I'm supposed to do in this environment. I bought the O'Reilly Flex 2 book and read it, but its really more of a generalised introduction that doesn't really tell me the logic behind things like this. I successfully develop Java/Swing/J2EE apps as well as PHP. I'm having a hard time getting my mind around the way Flex 2 does things.

            I wish the error messages messages were less vague.
            • 3. Re: error 1119 - text not compatable with String?
              chris.huston.t10 Level 3
              Sinc MACompany is a string variable it does not have a 'text' property like you are trying to access. This is the source of your error. The text property is only for TextInput and other Text controls that have an id property that you would then access the control's text value via the 'text' property. It would look like this:
              <mx:TextInput width="400" text="" id="MACtext"/>

              MACtext.text = "Some string value here";

              But if you want to bind a variable to a TextInput control, use the result handler function as Tracy suggested, and your code would look something like this:

              public var MACompany:String = new String();

              public function doLoginPage():void {
              loginPage.addEventListener("result", loginResult);

              //result handler that gets the xml data returned from the loginPage call.
              private function loginResult(evt:ResultEvent):void {
              MACompany = evt.result.MAData.MAAcount.MACompany;

              Then, in your mxml TextInput, you would bind to the variable like this:

              <mx:TextInput width="400" text="{MACompany}" />

              I hope this helps get your app working for you. Post back if you are still having problems.

              • 4. Re: error 1119 - text not compatable with String?
                jlmoller Level 1
                When I tried this, the

                <mx:TextInput width="400" text="{MACompany}" />

                gave me data binding warnings in the Flex Builder 2 compiler. When I tried to run it, I got error #1009's again when the SWF tried to reference the page that used the above line.

                • 5. Re: error 1119 - text not compatable with String?
                  chris.huston.t10 Level 3
                  Try this:

                  [Bindable] public var MACompany:String = new String();

                  This should take care of your warning, but do you still get the error now? Also, run a trace on your XML in the result function to make sure the XML is being returned properly:


                  Can you post a link to your app with the view source option? It might help in resolving this problem.
                  • 6. Re: error 1119 - text not compatable with String?
                    jlmoller Level 1
                    The [Bindable] addressed the error, and data is being passed back to where it is supposed to end up.