6 Replies Latest reply on May 10, 2006 3:12 AM by Dawntay

    Having a repeat loop in the background!

    retrobadger
      In flash you can have actionscipt loops going in the background through moviescript. Is something similar possible in Director! As I have a repeat loop which may go on for a considerable amount of time, and dont want it freezing the program if it does!
        • 1. Re: Having a repeat loop in the background!
          Level 7
          Repeat loops are not good to use in general for anything using animation.
          Doing things like 'repeat while the stillDown' is poor coding and should
          never be used. If you want a loop to happen, while other things are also
          allowed to happen, then either do it frame based, or do it with a timeout
          object. If you need more help, just ask.

          --
          Dave -
          Adobe Community Expert
          www.blurredistinction.com
          www.macromedia.com/support/forums/team_macromedia/


          • 2. Re: Having a repeat loop in the background!
            retrobadger Level 1
            Thankyou for your response Dave. Its not an animation, its an application im making, so you can go from frame to frame at the click of a button! But at the same time, I have a large database of online .txt files that I want it to read, which could take some time, so would like it to read these if the programming isn't doing anything else (so in the background).
            Cheers Dan
            • 3. Re: Having a repeat loop in the background!
              retrobadger Level 1
              Thankyou for your response Dave. Its not an animation, its an application im making, so you can go from frame to frame at the click of a button! But at the same time, I have a large database of online .txt files that I want it to read, which could take some time, so would like it to read these if the programming isn't doing anything else (so in the background).
              Cheers Dan
              • 4. Re: Having a repeat loop in the background!
                James Newton, ACP Level 3
                Director has an event named #enterFrame, which is sent to all behaviors and to an 'on enterFrame' movie script handler if there is one. This is a good place to put code that needs to be executed in the background without requiring any visual updates.

                Depending on how big the files are, you may be able to read one per frame without modifying the frame rate.

                Here's a pseudo-code behavior that you could add to a sprite that you place off-Stage:

                property pFileNameList

                on beginSprite(me)
                pFileNameList = ["list", "of", "files", "to", "read"]
                end beginSprite


                on enterFrame(me)
                if not pFileNameList.count then
                -- All files have been read in
                exit
                end if

                vFile = pFileNameList[1]
                pFileNameList.deleteAt(1)
                me.mReadInFile(vFile)
                end

                on mReadInFile(me, aFileName)
                -- Do what you have to do with the given file
                end
                • 5. Re: Having a repeat loop in the background!
                  retrobadger Level 1
                  Cheers for that, sadly the problem with on EnterFrame means that it causes noticeably pauses, being a program that I am making, clicking buttons will be an issue! Particularly, as its a list of getnettext() searches that need to be done! Is there no function that puts the loop at the bottom of a list of priorities, so a button click will be classified as more important!

                  Thanks for your help
                  Dan Duke
                  • 6. Re: Having a repeat loop in the background!
                    Dawntay
                    you could always make your loop as a seprate director file, import its as a dcr. (just like what happens with the flash loops )

                    You can use global vairables to comunicate between the too process.

                    Cheers

                    David