3 Replies Latest reply on Mar 12, 2009 8:07 AM by Ned Murphy

    delay in script?

    geiris
      hi guys!
      i want to have a delay in my script.
      i got this button called "btn3", that is scripted to cycle trough some pictures when i click it. like a slideshow. but...i want the pictures that is showing, to delay for a couple of second before it shows. within these seconds a door will close, and when it opens the next picture will be there. so you see, the picture can not switch before the door is closed.

      someone told me i sholud use "setInterval method", but how and where?
      here is the code for the btn3, i guess the delay should come here, or maby not...you tell me:)


      btn3.onRelease = function() {
      this.currentObj++;
      if (this.currentObj>6) {
      this.currentObj = 1;
      }
      var mc:MovieClip = tl.attachMovie("p"+this.currentObj+"ID","p"+this.c urrentObj+"MC",83);
      mc._x = px;
      mc._y = py;


      }
        • 1. delay in script?
          Ned Murphy Adobe Community Professional & MVP
          You'll need to reduce the button's participation to that of kicking things off by calling a separate function. The function will include the changing of the object to be displayed, then displaying it, and will end with a setInterval call that calls the function again. In this case, you would be better off using setTimeout instead oif setInterval because it does not require a clearInterval call.
          • 2. Re: delay in script?
            geiris Level 1
            i should told you that iam so wery wery new to flash.
            can you please show me how it should be scripted with setTimeout function?
            thanx
            • 3. delay in script?
              Ned Murphy Adobe Community Professional & MVP
              You should weally weally learn how to use the helps documents. Aside from the w's, that's a sincere suggestion, not a sarcastic one. They are your friend and can help you to learn as well as not have to ask others for help.

              Since you want the door to be involved in this process, you'd be better off having the door closing trigger a call to the function, and use the setTimeout to close the door when you want to change pictures.

              But in any case, here's the basic approach using the code you had, without the door in the picture. I am assuming that code works and haven't checked it for any revision needs..