3 Replies Latest reply on Oct 26, 2007 5:23 PM by natesnyder

    [object AsyncToken] Message

      I am trying to bind a function operation on a value and am getting a [object AsyncToken] message when I try to output the result. I have tested the function in ColdFusion and it returns the result correctly, so I must be doing something incorrect on the Flex site. I am including the code below and any help would be greatly appreachiated. Thank You.

      <mx:TextInput text="{svc.translateFundingSource(codeList_grd.selectedItem.FUNDING_SOURCE)}" id="test_ti"/>
        • 1. Re: [object AsyncToken] Message
          ChiefRocka00 Level 1
          I got that same error yesterday and was able to work around it. I was doing an HTTPService request which is asynchronous. I was trying to take the results of my HTTPService request and kick off something else. What I had to do was set the result of my HTTPService request as result="populateCurrentWeek(event)". Then in the populateCurrentWeek function set a variable equal to event.result. I then used that result to populate a button bar. Here are the code snippets from what I did.

          <mx:HTTPService id="getCurrentWeekNbr"
          url=" http://localhost/xmlData_getWeekNbr.php"

          public function populateCurrentWeek(event:ResultEvent):void {
          var rawData:String = String(event.result);
          var currentWeek:int = parseInt(rawData);

          weekSelected = currentWeek - 1;

          for ( var i:int = 1 ; i <= weekSelected ; i++ ) {

          weekButtonBar.dataProvider = buttonData;
          • 2. Re: [object AsyncToken] Message
            ntsiii Level 3
            Yes, the key here is ALL DATA SERVICE CALLS ARE ASYNCHRONOUS.

            The "send()" method of HTTPService and WebService and RemoteObject is an AsyncToken, NOT the result. You are trying to assing an AsyncToken to the text property and obvioulsy tht won't work.

            Async data calls are a hurdle for most new flex developers. In addition to the example above, here are som more snippets showing how to use HTTPService. It also shows usage of the AsyncToken, which you can ignore until you need it. Especially note the resultFormat="e4x". Use this always, you will be much happier.


            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
            • 3. Re: [object AsyncToken] Message
              natesnyder Level 1
              I undertand, but I would I use the result to bind to the selected item from my data grid?