1

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
gn66
  • 803
  • 2
  • 12
  • 33

1 Answers1

1

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.

gn66
  • 803
  • 2
  • 12
  • 33
  • I highly recommend looking into the Greensock framework. It has a programatic timeline library that allows you to control almost anything with a few simple lines of code (provided you've set everything up properly!) In addition, the tween libraries it comes with have handy delay and onComplete functions built in, so you can time all your animations and vars, referencing other functions and so on... http://greensock.com – MaxG Dec 02 '12 at 23:07