Gustavo,
Here is the link to the Flash Newbie discussion list.
http://chattyfig.figleaf.com/mailman/listinfo/flashnewbie
found at http://training.figleaf.com/resources/
As for this timer issue...
I just noticed your mixing intervals and onEnterFrames which there is really
no good reason for.
Considering you're only doing one thing (a timer), either specify a time
with setInterval/setTimeout or do a check with onEnterFrame, but not both.
An interval fires as close to specified time as possible, so unless the
countdown time is constantly changing (and/or you neeed frame by frame),
just use interval.
Moreover, since you only want to run it once, save yourself the trouble and
stick with a timeout if you can (Flash 8 feature).
//
// TIMEOUT VERSION
//
function llegamos ( ){
trace("llegamos");
_root.timerAction.gotoAndPlay(2);
}
function clearTimer () {
_global.clearTimeout ( timerInterval )
}
function startTimer () {
timerInterval = _global.setTimeout ( this, 'llegamos', 3000 );
}
startTimer ();
//
// INTERVAL VERSION
//
function checkTime()
{
stopTimer();
var currentTime:Number = getTimer();
var elapsedTime:Number = ( currentTime - startTime ) / 1000;
trace("llegamos " + elapsedTime );
tellTarget(_root.timerAction)
{
gotoAndPlay(2);
}
}
function startTimer()
{
startTime = getTimer(); // no var
timeCheck = setInterval( this, 'checkTime', 3000 ); // no var
}
function stopTimer()
{
clearInterval(timeCheck);
}
startTimer();
//
// ONENTERFRAME VERSION
//
function checkTime()
{
var currentTime:Number = getTimer();
if( currentTime >= later )
{
stopTimer();
var elapsedTime:Number = ( currentTime - startTime )/1000;
trace("llegamos " + elapsedTime );
tellTarget(_root.timerAction){
gotoAndPlay(2);
}
}
}
function startTimer()
{
startTime = getTimer(); // no var
later = (3 * 1000) + startTime; // no var
onEnterFrame = checkTime;
}
function stopTimer()
{
delete onEnterFrame;
}
startTimer();
_____________________________
Jesse Graupmann
www.jessegraupmann.com
www.justgooddesign.com/blog/
_____________________________
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Gustavo
Duenas
Sent: Sunday, April 01, 2007 6:19 PM
To: [email protected]
Subject: [Flashcoders] how to remove an event on a movie Clip( onEnterFrame)
Hi, I have a timer that someone of the flashcoder list gave me, it
works, the problem is what if the users discover the way of the
button (the code was made for all of them who doesn't know how to
find the buttom or are dumb enough for not to.) The timer works ok,
but what if I've clicked on the buttom, the timer is still in
progress and launches itself as previewed. there is a way to remove
the behaviour.
this is the code for the timer.
stop();
var startTime:Number = getTimer()/1000;
var later:Number = 20;
var timeCheck:Number = setInterval(checkTime, 100);
this.onEnterFrame = this.checkTime();
function checkTime(){
var currentTime:Number = getTimer()/1000;
var elapsedTime:Number = currentTime - startTime;
if(elapsedTime >= later){
trace("llegamos");
tellTarget(_root.timerAction){
gotoAndPlay(2);
}
clearInterval(timeCheck);
}
}
is on a movie clip with launches the event, but I want a way to
remove the event if the movieClip Logo has been clicked, or aq way to
put a code into the buttom some like on(releases){
removeMovieClip(this.timer);
or delete this.timer.OnEnterFrame;
so far the two doesn't work for launched as an event from the button,
so far anyone has ideas?
regards.
Gustavo Duenas
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com