Skip to main content
Known Participant
July 31, 2009
Question

If statement frustrating me.

  • July 31, 2009
  • 1 reply
  • 495 views

I just can't seem to get them down. I posted this yesterday but I just can't work it out. This is the current code before trying the if statement:

stop();
var my_timedReveal:Number = setTimeout(my_delayedReveal,15000,1);
function my_delayedReveal(arg1) {
gotoAndPlay("reveal2");
}
cardA.Mouse.addListener(mouseDown);
cardB.Mouse.addListener(mouseDown);
cardC.Mouse.addListener(mouseDown);
cardA.onRelease = function() {
gotoAndPlay("reveal1");
}
cardB.onRelease = function() {
gotoAndPlay("reveal2");
}
cardC.onRelease = function() {
gotoAndPlay("reveal3");
}


The problem is that even if a user clicks cardA, cardB or cardC, the timeout function still goes after 15 seconds and plays the "reveal2" frame.
Here's the if statement I tried to use:

stop();
cardB.Mouse.addListener(mouseDown);
cardC.Mouse.addListener(mouseDown);
cardA.onRelease = function() {
gotoAndPlay("reveal2");
}
cardC.onRelease = function() {
gotoAndPlay("reveal3");
}
var my_timedReveal:Number = setTimeout(my_delayedReveal,15000,1);
if (cardA.mouseDown == true) {
gotoAndStop("reveal1")
}
else {
my_delayedReveal = true;
}


What I want to happen is this. If a user clicks cardA, cardB, or cardC, go to the frame indicated ("reveal1" "reveal2" etc.).  If they don't click, then timeout function should go to the "reveal2" frame. But ONLY if they don't click.


Please help. I just can't seem to grasp this.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
July 31, 2009

it doesn't sound like you need an if-statement.  just clear your timeout if a card is clicked:

clearTimeout(my_timedReveal);  // use this in your onRelease methods.

Known Participant
July 31, 2009

YES!  You are GENIUS!  Thank you!  Thank you!  Thank you!

kglad
Community Expert
Community Expert
July 31, 2009

you're welcome.