-
AS2 getTimer delay reset issue
Hi All,
This is my first post here.
I am wrestling with an issue where i have 2 buttons which i want to use with a getTimer function.
If i do not click (no activity) on either button for more than 5 seconds i want it to visit a new frame - _root.gotoAndPlay(50);
However if i repeatedly multiple click the buttons - i want to remain on the same frame.
I tried to reset the getTimer to 0 so that when i click once then the counting starts from 0 again.
"delete onEnterFrame;" does not work if i put it in the 'if' statement.
I would be very grateful for any help on this one.
Code below:
var startTime:Number = getTimer();
this.onEnterFrame = function() {
var difference:Number = (getTimer() - startTime) / 1000;
if (difference < 5) {
joggleFlowUp.onRelease = function() {
flowAnimation.prevFrame();
}
joggleFlowDown.onRelease = function() {
flowAnimation.nextFrame();
}
}
else {
_root.gotoAndPlay(50);
delete onEnterFrame;
}
};
Last edited by misterbeck; 07-06-2016 at 06:55 AM.
-
.
Hi,
Maybe try using setInterval instead as onEnterFrame is a bit squishy.
PHP Code:
stop();
var difference:Number = 0;
function doTimer():Void
{
difference += .1;
trace(difference);
if (difference < 5)
{
joggleFlowUp.onRelease = function():Void
{
flowAnimation.prevFrame();
difference = 0;
};
joggleFlowDown.onRelease = function():Void
{
flowAnimation.nextFrame();
difference = 0;
};
}
else
{
clearInterval(theTimer);
_root.gotoAndPlay(50);
}
}
var theTimer = setInterval(doTimer, 100);
I am sure you can modify this to your own neeeds.
-
Originally Posted by fruitbeard
Hi,
Maybe try using setInterval instead as onEnterFrame is a bit squishy.
PHP Code:
stop();
var difference:Number = 0;
function doTimer():Void
{
difference += .1;
trace(difference);
if (difference < 5)
{
joggleFlowUp.onRelease = function():Void
{
flowAnimation.prevFrame();
difference = 0;
};
joggleFlowDown.onRelease = function():Void
{
flowAnimation.nextFrame();
difference = 0;
};
}
else
{
clearInterval(theTimer);
_root.gotoAndPlay(50);
}
}
var theTimer = setInterval(doTimer, 100);
I am sure you can modify this to your own neeeds.
-
Awesome.
Thank you so much Fruitbeard. Quickly installed the code and it works like a dream... and i actually understand it!
cheers
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|