Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-30-2004, 02:19 PM   #1
aperez
Registered User
 
Join Date: Oct 2003
Posts: 8
Default Simple Counter

I am a newbie at actionscript.
I am creating a simple 10 question quiz.
I would like to create a counter of seconds and minutes.
I want to display the counter on screen while taking the quiz.
I also would like to display the time that it took to complete the quiz.

Are there any tutorials already created for this purpose

any help would really be appreciated

thanks

aperez
aperez is offline   Reply With Quote
Old 05-30-2004, 02:56 PM   #2
boyzdynasty
Senior Member
 
boyzdynasty's Avatar
 
Join Date: Aug 2002
Location: Philly
Posts: 2,583
Default

hmm....i don't know of any tutes out there, but I don't think it's much to it.

Just use setInterval

I copied and paste this from the as 2.0 dictionary
Code:
setInterval()
Availability
Flash Player 6.

Usage
setInterval(functionName, interval [, param1, param2, ..., paramN])

Parameters
functionName A function name or a reference to an anonymous function.

interval The time in milliseconds between calls to the functionName parameter.

param1, param2, ..., paramN Optional parameters passed to the function or methodName parameter.

Returns
An interval identifier that you can pass to clearInterval() to cancel the interval.

Description
Function; calls a function or a method or an object at periodic intervals while a SWF file plays. You can use an interval function to update variables from a database or update a time display.

If interval is less than the SWF file's frame rate (for example, 10 frames per second [fps] is equal to 100 milliseconds), the interval function is called as close to interval as possible. You must use the updateAfterEvent() function to make sure that the screen refreshes often enough. If interval is greater than the SWF file's frame rate, the interval function is only called each time the playhead enters a frame; this minimizes the impact each time the screen is refreshed.

Example
Usage 1:The following example calls an anonymous function every 1000 milliseconds (every 1 second).

setInterval( function(){ trace("interval called"); }, 1000 );

Usage 2: The following example defines two event handlers and calls each of them. Both calls to setInterval() send the string "interval called" to the Output panel every 1000 milliseconds. The first call to setInterval() calls the callback1() function, which contains a trace() action. The second call to setInterval() passes the "interval called" string to the function callback2() as a parameter.

function callback1() {
  trace("interval called"); 
}

function callback2(arg) { 
  trace(arg);
}

setInterval( callback1, 1000 ); 
setInterval( callback2, 1000, "interval called" );

Usage 3: This example uses a method of an object. You must use this syntax when you want to call a method that is defined for an object. 

obj = new Object();
obj.interval = function() { 
  trace("interval function called"); 
}

setInterval( obj, "interval", 1000 ); 

obj2 = new Object();
obj2.interval = function(s) { 
  trace(s); 
}
setInterval( obj2, "interval", 1000, "interval function called" ); 

You must use the second form of the setInterval() syntax to call a method of an object, as follows:

setInterval( obj2, "interval", 1000, "interval function called" ); 

See also
clearInterval(), updateAfterEvent()
__________________
I need a new signature!
boyzdynasty is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:37 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.