1 Reply Latest reply on Sep 29, 2006 12:15 AM by Newsgroup_User

    URLLoader

    wally_errrr
      HI there,

      Just wondering if someone can give me some clues on what to do.

      I have a class that loads some text from files using the URLLoader class and the URLRequest class.

      I then have a method that performs operations on the loaded text. The problem i am having is that i don't know when i am able to call the methods that access the data, as if I instantiate the class and then call a method before the data is finished loading then it will fail.

      I was thinking of setting a flag inside the class that would be set once the last text has loaded, but I am not sure how to monitor that. I was thinking of sitting in a while loop until the flag is set, but this doesn't seem the most elegant way to go about it.

      I am not knowledgeable on design patterns, so is there a design pattern that would help me out here

      Any ideas?

      Cheers,

      Nathan
        • 1. Re: URLLoader
          Level 7

          "wally_errrr" <webforumsuser@macromedia.com> wrote in message
          news:efhtkf$5bb$1@forums.macromedia.com...
          > HI there,
          >
          > Just wondering if someone can give me some clues on what to do.
          >
          > I have a class that loads some text from files using the URLLoader class
          > and
          > the URLRequest class.
          >
          > I then have a method that performs operations on the loaded text. The
          > problem
          > i am having is that i don't know when i am able to call the methods that
          > access
          > the data, as if I instantiate the class and then call a method before the
          > data
          > is finished loading then it will fail.
          >
          > I was thinking of setting a flag inside the class that would be set once
          > the
          > last text has loaded, but I am not sure how to monitor that. I was
          > thinking of
          > sitting in a while loop until the flag is set, but this doesn't seem the
          > most
          > elegant way to go about it.
          >
          > I am not knowledgeable on design patterns, so is there a design pattern
          > that
          > would help me out here
          >
          > Any ideas?
          >
          > Cheers,
          >
          > Nathan
          >

          This question should be asked in a Flash 9 / ActionScript 3.0 group... not
          here.

          Looks like
          http://livedocs.macromedia.com/labs/as3preview/docs/wwhelp/wwhimpl/common/html/wwhelp.htm? context=LiveDocs_Parts&file=00000138.html
          might have the answer you are looking for... see the
          addEventListener(Event.COMPLETE...) line