[Tweener] Timer based Tweener
Zeh Fernando
zeh at zehfernando.com
Thu Dec 3 12:18:52 PST 2009
This has actually been an item on the to-do list since the introduction of
the AS3 version - to support arbitrary FPSs for updating. It's not something
that should be done all the time, but it's a nice feature to have for
specific tweens.
The core won't be changed since Tweener is considered a 'finished' project,
but of course everyone can still modify it to add the feature.
Thanks for sharing!
Zeh
On Thu, Dec 3, 2009 at 2:19 PM, Kevin Newman <CaptainN at unfocus.com> wrote:
> I'm doing a project now that has to load old 12 FPS movies and wanted my
> Tweener based widget interaction to be smoother than 12 FPS is capable of.
> So I hacked Tweener to add Timer/updateAfterEvent support.
>
> This is hacky and unfinished, but it does show how this could work. Is
> there any interest in adding something like this to the core, or as a
> special property or something?
>
> Here is the modified code, if you are interested:
>
> /**
> * Starts the Tweener class engine. It is supposed to be running every time
> a tween exists.
> */
> private static function startEngine():void {
> _engineExists = true;
> _tweenList = new Array();
>
> __tweener_controller__ = new MovieClip();
> __tweener_controller__.addEventListener(Event.ENTER_FRAME,
> Tweener.onEnterFrame);
>
> // Added Timer stuff
> __timer = new Timer(1000 / 30);
> __timer.addEventListener(TimerEvent.TIMER, onTimer);
> __timer.start();
>
> _currentTimeFrame = 0;
> updateTime();
> }
>
> /**
> * Implements a Timer updater to enable updates faster than the document
> framerate.
> */
> static var __timer:Timer;
> static function onTimer(evt:TimerEvent):void {
> __tweener_controller__.dispatchEvent(new Event(Event.ENTER_FRAME));
> evt.updateAfterEvent();
> }
>
> /**
> * Stops the Tweener class engine.
> */
> private static function stopEngine():void {
> _engineExists = false;
> _tweenList = null;
> _currentTime = 0;
> _currentTimeFrame = 0;
> __tweener_controller__.removeEventListener(Event.ENTER_FRAME,
> Tweener.onEnterFrame);
> __tweener_controller__ = null;
>
> // Added Timer stuff
> __timer.stop();
> __timer.removeEventListener(TimerEvent.TIMER, onTimer);
> __timer = null;
> }
>
>
> This is far from polished, but shows how this can work. If you were to run
> this in a project set to 1 FPS, you'd still get 30 FPS updates on Tweener
> based Tweens.
>
> Kevin N.
>
>
> _______________________________________________
> Tweener mailing list
> Tweener at lists.caurinauebi.com
> http://lists.caurinauebi.com/listinfo.cgi/tweener-caurinauebi.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.caurinauebi.com/pipermail/tweener-caurinauebi.com/attachments/20091203/23266d6f/attachment.htm>
More information about the Tweener
mailing list