2 Replies Latest reply on Aug 7, 2007 3:18 AM by pdm123

    ROC call

    pdm123
      I am new to flex and I tried to retrive and set the data from the bean in to textinput with inthe same mxml file I could set and retrive the data but how do I get the previously set data into next form. I am using ROC to communicate my code is as below

      <b>first mxml file</b>

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="_myFunc()">
      <mx:RemoteObject id="srv" destination="test3" />
      <mx:Script>
      <![CDATA[
      import mx.controls.Alert;
      import flash.net.navigateToURL;
      public var s:String;
      public function _myFunc():void{

      s=srv.getUser();
      //userName.text=srv.getUser.lastResult;
      //Alert.show(s);
      }
      public function setUser():void{

      srv.setUser(userName.text);
      var u:URLRequest = new URLRequest("next.mxml");
      navigateToURL(u, "_self");
      }
      ]]>
      </mx:Script>
      <mx:Form x="59" y="66" width="176" >
      <mx:TextInput id="userName" text="{srv.getUser.lastResult}" width="101" />
      <mx:Button label="Button" click="setUser();"/>
      </mx:Form>

      </mx:Application>


      <b>Second mxml file</b>

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="getUser1()">
      <mx:RemoteObject showBusyCursor="true" id="srv" destination="test3" />
      <mx:Script>
      <![CDATA[
      import mx.controls.Alert;
      import flash.net.navigateToURL;
      public var s:String;
      public function getUser1():void{

      s=srv.getUser();
      //userName.text=srv.getUser.lastResult;
      //Alert.show(s);
      }

      ]]>
      </mx:Script>

      <mx:TextInput x="134" y="77" text="srv.getUser.lastResult;"/>

      </mx:Application>



        • 1. Re: ROC call
          ntsiii Level 3
          All data service calls in flex are asynchronous. You must use a result handler to acces the returned data. This will NOT work:
          s=srv.getUser();
          "s" will never have data.

          Tracy
          • 2. Re: ROC call
            pdm123 Level 1
            Thanks Tracy got my mistake. I have a question, we got to work on a intranet web based application, what do you think is the best option httpServices or Remote object calls.
            Thanks