| View previous topic :: View next topic |
| Author |
Message |
Elec0 Expert Cheater
Reputation: 0
Joined: 21 Nov 2007 Posts: 188 Location: Out of my mind, back in five minutes.
|
Posted: Fri Dec 21, 2007 1:06 pm Post subject: Need help with timers in Flash |
|
|
I cannot figure out how to make a working timer. I will post my code here, I hope that someone can either find an error with my code or tell me how to make a working timer.
| Code: |
import flash.display.Sprite;
import flash.events.TimerEvent;
import flash.utils.Timer;
//class ShortTimer extends Sprite
//{
function ShortTimer()
{
// creates a new five-second Timer
var minuteTimer:Timer = new Timer(1000, 10);
// designates listeners for the interval and completion events
minuteTimer.addEventListener(TimerEvent.TIMER, onTick);
minuteTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
// starts the timer ticking
minuteTimer.start();
}
function onTick(event:TimerEvent):void
{
// displays the tick count so far
// The target of this event is the Timer instance itself.
trace("tick " + event.target.currentCount);
t.text = "tick " + event.target.currentCount;
}
function onTimerComplete(event:TimerEvent):void
{
trace("Time's Up!");
}
//}
|
~Elec0
_________________
|
|
| Back to top |
|
 |
Angemon102 Master Cheater
Reputation: 0
Joined: 08 Sep 2007 Posts: 408 Location: Karachi
|
Posted: Fri Dec 21, 2007 1:40 pm Post subject: |
|
|
| What is this? VB6? VB08? .NET?
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
|
| Back to top |
|
 |
Elec0 Expert Cheater
Reputation: 0
Joined: 21 Nov 2007 Posts: 188 Location: Out of my mind, back in five minutes.
|
Posted: Fri Dec 21, 2007 2:08 pm Post subject: |
|
|
I used this code:
| Code: |
stop();
package {
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.display.Sprite;
public class TimerEventExample extends Sprite {
public function TimerEventExample() {
var myTimer:Timer = new Timer(1000, 2);
myTimer.addEventListener(TimerEvent.TIMER, timerHandler);
myTimer.start();
}
public function timerHandler(event:TimerEvent):void {
trace("timerHandler: " + event);
}
}
}
|
And got this error:
| Code: |
1083: Syntax error: package is unexpected.
|
Any help?
~Elec0
_________________
|
|
| Back to top |
|
 |
|