5 Replies Latest reply on Jul 10, 2006 9:17 PM by kglad

    Delaying

    KillerHurdz Level 1
      Hey, I will try to explain my problem as best as I can without it being too complicated... here goes.

      Me and a friend have created a new flash website. Now, on the top navigational bar... if you press on one of the buttons to go to a differen't "page" on the site, you can see that the "doors" close then open. When the doors open, you are at a new page. The only problem is that we want it so that the page that you are leaving doesn't disapear until the doors are closed, then once they open, the new site is there. It will be very complicated to fix this and we don't want to redo some of the code. So my suggestion is that we put some sort of delay in front of the code that tells the site to "delete" the previous page and move on.

      We need a Delay function in front of the script because it doesnt use frames to tell it what to do (so we can't just add frames to slow down the process).

      So my question is... can you use a delay function in front of a code? For example, something like this (no this is not the real code, I know)

      Delay(20);
      [Code]
      asdf
      asdf
      asdf
      [/Code]

      Or w/e...

      Anyways, can someone tell me if this is possible? And if so, how would we go about doing it? We are not very advanced in Flash and if there is a simple code that will do it, that would be awesome.

      Thx in advance,
      KillerHurdz.
        • 1. Re: Delaying
          kglad Adobe Community Professional & MVP
          i'm not sure how you're going to use a delay function to solve your problem, but you can use setInterval() to delay the execution of any block of code.

          simply place the code you wish to execute (after a delay) within a function, call that function using setInterval() using the delay you want in your 2nd setInterval() parameter and clear the interval within the function.
          • 2. Re: Delaying
            KillerHurdz Level 1
            Could you show me an example code of what I would put in before the code that I want to be delayed? I am not familiar with the setInterval() code...

            Thx again.
            • 3. Re: Delaying
              kglad Adobe Community Professional & MVP
              try:

              • 4. Re: Delaying
                KillerHurdz Level 1
                Sry, newb... here is what my code looks like after I added the code you supplied...

                codeToExecuteI=setInterval(codeToExecuteF,timeDelayInMilliseconds);

                function codeToExecuteF(){
                clearInterval(codeToExecuteI);
                // put the code that you want to execute after timeDelayInMilliseconds here
                }
                on (release) {
                if(this.clips == Number(this.clips)){
                loadMovieNum("home.swf",this.clips);
                } else {
                this.clips.loadMovie("home.swf");
                }
                //Movieclip GotoAndPlay Behavior
                this.rollin.gotoAndPlay("1");
                //End Behavior
                }
                on (rollOver) {

                //Movieclip GotoAndPlay Behavior
                this.bu1.gotoAndPlay("2");
                //End Behavior

                }


                I am getting some errors. If it matters, this code is on the button that when you press it, goes to the "Home" page. Sry, never used this code before and have no idea how it works... I'm probably doing something that is easily fixable but because I don't really "get" the code, could somebody help me out a bit?

                Thx again for the trouble,
                KillerHurdz.
                • 5. Re: Delaying
                  kglad Adobe Community Professional & MVP
                  first, timeDelayInMilliseconds needs to be defined.

                  second, there's no code in codeToExecuteF().

                  third, what's the code you did list have to do with this?