Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Need help with timers in Flash

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
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.

PostPosted: Fri Dec 21, 2007 1:06 pm    Post subject: Need help with timers in Flash Reply with quote

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
View user's profile Send private message MSN Messenger
Angemon102
Master Cheater
Reputation: 0

Joined: 08 Sep 2007
Posts: 408
Location: Karachi

PostPosted: Fri Dec 21, 2007 1:40 pm    Post subject: Reply with quote

What is this? VB6? VB08? .NET?
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Dec 21, 2007 1:42 pm    Post subject: Reply with quote

Angemon102 wrote:
What is this? VB6? VB08? .NET?


It's ActionScript 3.

@Elec: Take a look at the language reference from Adobe for the timers:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/TimerEvent.html

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Elec0
Expert Cheater
Reputation: 0

Joined: 21 Nov 2007
Posts: 188
Location: Out of my mind, back in five minutes.

PostPosted: Fri Dec 21, 2007 2:08 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites