I'm trying to ma开发者_Go百科ke use of a package that someone else has written in my Flash AS3 programme. I can't work out how to include it however, nothing I try seems to work. The package is here:
http://cookbooks.adobe.com/post_Accurate_timer-17332.html
Any help much appreciated!
You can use it on the timeline as shown in the example, or use it in a document class as shown below (OldTimer.as):
package
{
import flash.display.Sprite;
import flash.events.TimerEvent;
/**
*
*
*/
public class OldTimer extends Sprite
{
private var tmr: AccurateTimer
private var m_time: Date
public function OldTimer()
{
tmr = new AccurateTimer( 1000, 10 );
tmr.addEventListener( TimerEvent.TIMER, onTmr );
tmr.addEventListener( TimerEvent.TIMER_COMPLETE, ontmrC );
tmr.start();
m_time = new Date();
}
private function onTmr( evnt: TimerEvent ): void
{
var newTime: Date = new Date();
trace( "Timer: ", newTime.time - m_time.time );
m_time = newTime;
}
private function ontmrC( evnt: TimerEvent ): void
{
var newTime: Date = new Date();
trace( "Complete: ",newTime.time - m_time.time );
m_time = newTime;
}
}
}
Reference the document class in the IDE via the Properties panel. Select the Stage and the enter the name of the Class eg OldTimer (without the .as extension)
精彩评论