Here is my sample code to demonstrate you the concept of setting
interval (reset automatically if user fail to answer quiz in given
time), interrupting interval and refreshing it (when user answer the
quiz within given time, represented by onMouseDown event).

Copy and paste all code into fresh FLA and test run it. If you don't
click on the stage, the movie will refresh to next round in 3 secs
unless you click on the stage to interrupt the timer, once you stop
clicking, timer will go back to it's normal routine.

[CODE]

var timeFrame = 3000;   // interval per question
var count = 0;          // counter

onLoad = function(){
        _root.createTextField("txt",10,10,10,50,20);
        setTimer();
}

function setTimer(){
        clearInterval(intIdle);
        intIdle = setInterval(nextRound, timeFrame);    
}

// Kill timer permanently
function killTimer(){
        clearInterval(intIdle);
}

function nextRound(){
        // actions you want to perform when time's up
        txt.text = "Round " + (count++);
        txt._x += 15;
        setTimer(); // reset new timer
}

onMouseDown=function(){
        nextRound();
}

[/CODE]


[...]   Sam Liu
Flash Developer - Languages Online
Office of Learning and Teaching
Department of Education and Training
 

T:  (03) 9637 2102    F:  (03) 9637 2060

 


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Weyert
de Boer
Sent: Monday, 31 October 2005 9:36 AM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] setInterval() and the trouble


I got some stuff working now ;-=)
Looks like I had some infinite loop indeed. Pff.
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Important - 
This email and any attachments may be confidential. If received in error, 
please contact us and delete all copies. Before opening or using attachments 
check them for viruses and defects. Regardless of any loss, damage or 
consequence, whether caused by the negligence of the sender or not, resulting 
directly or indirectly from the use of any attached files our liability is 
limited to resupplying any affected attachments. Any representations or 
opinions expressed are those of the individual sender, and not necessarily 
those of the Department of Education & Training.
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to