노무현 대통령 배너

Tag: addEventListener

Timer Class를 이용한 원하는 시간에 원하는 일 하기 F1 대로 구현

by on 12.12, 2008, under AS3.0 API

플생사모에 올라온 글에 대한 답변입니다.

http://cafe.naver.com/flashdev/34255

Timer Class 의 F1에 있는 예제 그대로 사용하였습니다.

http://livedocs.adobe.com/flash/9.0_kr/main/00000074.html

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package {
	import flash.display.Sprite;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
 
	public class ShortTimer extends Sprite {
		public function ShortTimer() {
			// creates a new five-second Timer
			var minuteTimer:Timer = new Timer(1000,5);
 
			// 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();
		}
 
		public 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);
 
			//원하는 시간에 원하는 일 간단하게 if 문으로 실행
			if (event.target.currentCount == 3) {
				trace("3초에 할일");
				//A1.addChild (B);
			} else if (event.target.currentCount == 4) {
				trace("4초에 할일");
				//A1.addChild (C);
			}
		}
 
		public function onTimerComplete(event:TimerEvent):void {
			trace("Time's Up!");
		}
	}
}

네이버 카페, 트랙백좀 지원했으면….

댓글남기기 :, , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Meta