チェンジセット 3610
- コミット日時:
- 2010/03/26 01:33:56 (3 年前)
- ファイル:
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/Player.as
r3583 r3610 1 1 package org.libspark.gunyarapaint.framework 2 2 { 3 import flash.events.TimerEvent; 3 4 import flash.utils.ByteArray; 5 import flash.utils.Timer; 4 6 import flash.utils.clearInterval; 5 7 import flash.utils.setInterval; … … 21 23 parser.preload(); 22 24 speed = 1; 23 duration = 50;24 m_timer ID = 0;25 m_timer = new Timer(50); 26 m_timer.addEventListener(TimerEvent.TIMER, process); 25 27 m_parser = parser; 26 28 var version:uint = data.version; … … 55 57 public function start():void 56 58 { 57 if ( m_timerID === 0) {58 m_timer ID = flash.utils.setInterval(process, duration);59 if (!m_timer.running) { 60 m_timer.start(); 59 61 if (hasEventListener(PlayerEvent.STARTED)) 60 62 dispatchEvent(new PlayerEvent(PlayerEvent.STARTED)); … … 72 74 public function pause():void 73 75 { 74 stopTimer(); 75 if (hasEventListener(PlayerEvent.PAUSED)) 76 dispatchEvent(new PlayerEvent(PlayerEvent.PAUSED)); 76 if (m_timer.running) { 77 m_timer.stop(); 78 if (hasEventListener(PlayerEvent.PAUSED)) 79 dispatchEvent(new PlayerEvent(PlayerEvent.PAUSED)); 80 } 77 81 } 78 82 … … 87 91 public function stop():void 88 92 { 89 stopTimer(); 90 m_parser.rewind(); 91 m_parser.resetCommands(); 92 if (hasEventListener(PlayerEvent.STOPPED)) 93 dispatchEvent(new PlayerEvent(PlayerEvent.STOPPED)); 93 if (m_timer.running) { 94 m_timer.stop(); 95 m_parser.rewind(); 96 m_parser.resetCommands(); 97 if (hasEventListener(PlayerEvent.STOPPED)) 98 dispatchEvent(new PlayerEvent(PlayerEvent.STOPPED)); 99 } 94 100 } 95 101 96 private function process( ):void102 private function process(event:TimerEvent):void 97 103 { 98 104 try { … … 107 113 } 108 114 catch (e:Error) { 109 stopTimer();115 m_timer.stop(); 110 116 if (e is EOLError) { 111 117 m_parser.rewind(); … … 120 126 } 121 127 } 122 }123 124 private function stopTimer():void125 {126 flash.utils.clearInterval(m_timerID);127 m_timerID = 0;128 128 } 129 129 … … 152 152 public function get playing():Boolean 153 153 { 154 return m_timer ID != 0;154 return m_timer.running; 155 155 } 156 156 … … 162 162 163 163 /** 164 * ログの長さ164 * 動作間隔(ミリ秒) 165 165 * 166 166 */ 167 public var duration:uint; 167 public function set duration(value:uint):void 168 { 169 m_timer.delay = value; 170 } 168 171 169 172 private var m_parser:Parser; 170 private var m_timer ID:uint;173 private var m_timer:Timer; 171 174 } 172 175 }

