3 Replies Latest reply on Aug 11, 2008 7:17 AM by Newsgroup_User

    How to use "callLater"?

    mark416 Level 1
      I am confusing how to use callLater and when I will use it.

      Thanks

      Mark
        • 1. Re: How to use "callLater"?
          slaingod Level 1
          I typical way to use it would be to do:

          callLater(function ():void {
          something.visible = false;
          })

          or

          callLater(function (someArg:String):void {
          something.text = someArg;
          }, 'Something')

          In general, it can be a cheap way to get around some timing issues. I've used it to set an event listener on an embedded swf...but this is probably cheating. Sometimes it is useful for when you make some changes to some properties, but some other code might change them as well, and you want to make sure something happens after all of the updates occur.

          A much more use method would be (I don't think this exsits):
          callIn(100, function....)
          where 100 would be milliseconds and would automatically create and destroy a timer.








          • 2. Re: How to use "callLater"?
            atta707 Level 2
            setInterval and setTimeout function would be equivelant of callIn.
            • 3. Re: How to use "callLater"?
              Level 7

              "slaingod" <webforumsuser@macromedia.com> wrote in message
              news:g7ofme$89s$1@forums.macromedia.com...
              >I typical way to use it would be to do:
              >
              > callLater(function ():void {
              > something.visible = false;
              > })
              >
              > or
              >
              > callLater(function (someArg:String):void {
              > something.text = someArg;
              > }, 'Something')
              >
              > In general, it can be a cheap way to get around some timing issues. I've
              > used
              > it to set an event listener on an embedded swf...but this is probably
              > cheating.
              > Sometimes it is useful for when you make some changes to some properties,
              > but
              > some other code might change them as well, and you want to make sure
              > something
              > happens after all of the updates occur.
              >
              > A much more use method would be (I don't think this exsits):
              > callIn(100, function....)
              > where 100 would be milliseconds and would automatically create and destroy
              > a
              > timer.

              I don't think most people are using callLater with anonymous functions. A
              more typical thing to do would be this:

              private function init():void{
              //set dataProvider on component that hasn't been created yet
              callLater(setDataProvider());
              }

              private function setDataProvider():void{
              myNewlyCreatedComponent.dataProvider=foo;
              }

              This can help resolve some race conditions. However, the longer you work
              with Flex, the less you will use this, since you'll get more insight on
              which part of the component lifecycle is the best place to put such logic.
              Additionally, since many List Based components will measure only one
              instance of one renderer before deciding how to lay themselves out and will
              not refresh or revisit this, using callLater on anything that will affect
              the size of the component is unwise.