timer « Actionscript Programming « Flash Tutorials

Home
Flash Tutorials
1.Actionscript Programming
2.Animals
3.Animation
4.Colors
5.Design
6.Effects
7.Game Cartoon
8.Humans
9.Models
10.Nature
11.Operations
12.Shapes
Photoshop Tutorials
Maya Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
Flash Tutorials » Actionscript Programming » timer 
var timeClock:Timer = new Timer(100);

12 Free Online Quiz Creators for Teaching Online Last post by: Sunnyme Date: 01.10.2009 06:26:27

There are a few ways to create a timing system in Flash, and this is the way with less Actionscript that was used in the Create a Simple Avoiding Game tutorial, but several people have commented that they had trouble with it, so here's a more in-depth tutorial on how to create a simple timer in Flash which can be used to keep a score, or advance levels, or whatever you need!

I will also show you how to make a standard game timer, with just a few tweaks of the actionscript.

After a bit of play, I've gotten “if statements” and the sort to work. In short, the setInterval function creates it's own “little world” within Flash, and only the code within setInterval will update at the interval you set (in this case, every second - hence the variable 'timer' is increased by 1 every second). In order to use this timer for something more than just numbers increasing, you'll need to add extra code into the setInterval function. Growing on Awesty's code, you could do this (NOTE: I'm counting up, not down):

The last line of code will be placed after the } and this is the timer, it says to repeat the code every second.

12 Free Online Quiz Creators for Teaching Online Last post by: Sunnyme Date: 01.10.2009 06:26:27

1. Open up a new Flash Document. Make 2 layers. Name one actions and the other timer. First we will add all of the objects and then throw all of our actionscript together. *Note: This tutorial was written using flash mx 2004 with ActionsScript 2.0 strict variable typing. It is not required by flash, but it is a very good programming practice and will help flash out immensely with debugging your movie if you ever have errors. If you are using Flash mx please just remove all of the datatypes like :Number or :String.

Add him a Instance name "count_down" (It's important to don't change this name, or you have to change name in code later)

This tutorial was written for the Flash Designer software, which allows you to create flash animations in a much easier way than by using Macromedia Flash. You may get Flash Designer here.

www_._ja___v___a_2___s___.c_o___m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.