gn66
gn66

Reputation: 853

Action Script 3, Flash Cs6 How do I create a time delay?

I'm making a website and I want to make a time delay between 16 pages, I've done this:

var myDelay:Timer = new Timer(700,1);

myDelay.addEventListener(TimerEvent.TIMER, showMessage);
myDelay.start();

function showMessage(event:TimerEvent):void{
    gotoAndPlay("anim1");
}
stop();

Then In page anim1 I have:

stop();

b4.addEventListener(MouseEvent.ROLL_OVER, b4_over);
b4.addEventListener(MouseEvent.CLICK, b4_clicked);
ma.addEventListener(MouseEvent.ROLL_OVER, ma_over);
ma.addEventListener(MouseEvent.CLICK, ma_clicked);
pt1.addEventListener(MouseEvent.MOUSE_OVER, pt1_over);
en.addEventListener(MouseEvent.MOUSE_OVER, en_over);

var myDelay2:Timer = new Timer(700,1);
myDelay2.addEventListener(TimerEvent.TIMER, showMessage2);
myDelay2.start();

function showMessage2(event:TimerEvent):void{
   gotoAndPlay("anim2");
}
stop();

And this continues until page "anim19". The problem is that with this my click buttons don't work very well (I click, then I go to another page and suddenly goes back to the main page) and with the ROLL_OVER effect time becomes a litle weird... Can you tell me what's wrong with my code?

Upvotes: 1

Views: 1757

Answers (1)

gn66
gn66

Reputation: 853

I figure it out what was wrong, aparently I'm starting time and not finish it in here:

myDelay.start();

So every delay must have the stop event so i added in the functions b4_over, b4_clicked, ma_over, ma_clicked, pt1_over, en_over)

like this:

function b4_over(event:MouseEvent):void
{
    this.gotoAndStop("page2");
    myDelay.stop();
    myDelay.stop(); 
    myDelay2.stop();
    myDelay3.stop();
    myDelay4.stop();
    myDelay5.stop();
    myDelay6.stop();
    myDelay7.stop();
    myDelay9.stop();
    myDelay10.stop();
    myDelay11.stop();
    myDelay12.stop();
    myDelay13.stop();
    myDelay14.stop();
    myDelay15.stop();
    myDelay16.stop();
    myDelay17.stop();
    myDelay18.stop();
    myDelay19.stop();   
}

And everything started to work together just fine.

Upvotes: 1

Related Questions