5 Replies Latest reply on Aug 22, 2007 8:06 PM by ntsiii

    CallLater question

    levancho Level 3
      I have calllater in my method that recursively calls same method it is in, until result of some other http service is not back.
      is it an overkill? to use calllater like that? I just want to understand "calllater "'s correct usage. :

      private function modifyOwnerDataList(): void {

      if( cdl.lastResult!=null ){
      var entries:ArrayCollection = cdl.lastResult.DataList.Owner.O

      var myObj:Object = {label:"All",data:"All"};

      this.vmownerComboBox.data = entries;
      else {
        • 1. Re: CallLater question
          ntsiii Level 3
          Why not use the result event of the HTTPService call?
          • 2. CallLater question
            levancho Level 3
            because that particular component gets created way after result is back for cdl service, but there are cases that this component can be created before result is back from that service, and I want to make sure that dropedow has valies it int as soon as that service is back .
            • 3. Re: CallLater question
              flexPro Level 1
              Listen to Tracy... use the result event. Using callLater as you do above is definitely NOT the correct usage and will be horribly inefficient. If the component is sometimes created after the result is returned, then store the result in a variable, and bind the values in the comboBox to that variable. In this way, it won't matter if the comboBox is created first or the values are returned first. For example:

              <ComboBox dataProvider="{entries}" />

              ...then, in your Script tag...

              private var entries:ArrayCollection;

              public function result(data:Object):void {
              entries = ArrayCollection(data.result);
              entries.addItemAt(0, {label:"All",data:"All"});
              • 4. CallLater question
                levancho Level 3
                Thanks guys for suggestions, but if you permit, I want to play stuborn for sake of interest and put on table Binding vs calllater overhead for attribute that will not change once its back from Service.
                now as I see Recursive Calls to method using callLater executes for every frame untill condition is not satisfied , so lets say Hypothetically until service is back 100 frames passed, method executes , method local variables get Garbage collected , same with Method (since in EcmaScript world methods are objects :)). itself it gets garbage collected, . so I have extra overhead only during 100 frames of calling this method over and over again
                on other hand I bind that attribute and yes service is back attribute is modified ,event is fired etc etc and comboBox data is updated but attribute stay in memory so all the acoossiated Binding records, and listeners, so my question is is there really a big difference or even more daring question is not binding more resurce intesinve in this case?

                • 5. Re: CallLater question
                  ntsiii Level 3
                  There is rarely only one solution to anything. Go for it if you want.