It's no secret that Timer (even setInterval) is not accurate. It drifts quickly as event-handling lags get compounded with each cycle. This might come up when say, building a video-sequencing app or something similar.
It's also no secret that part of GoASAP's mission is to promote the idea of various animation systems being able to combine their processing. Large numbers of animations process the fastest when they're all kept in a single list, and that list is updated "on the beat" all at once.
Adobe could address these issues with an additional player-level timer class:
package flash.animation {
public final class SyncTimer {
public static function addCallback(closure:Function,
interval:Object="enterFrame",
priority:int=0):void;
public static function removeCallback(closure:Function):Boolean;
public static function pause(interval:Object=null):void;
public static function resume(interval:Object=null):void;
}}
This hypothetical class might use callbacks instead of events for speed. It would always use weak references to avoid trapping object references. Intervals other than ENTER_FRAME would ideally be corrected for lag, so they stay as close to accurate as possible.
This might provide a real performance boost for larger numbers of animations. And importantly, all animation systems could be synced very tightly from one centralized update list, making them work much better together.
This feature would lay the groundwork for Adobe to provide a base animation package in AS3, a set of core classes that both their own and also 3rd-party systems could be built on, eliminating a lot of the redundancies between these overlapping systems. (Currently Flash and Flex don't even share an easing package!)
import flash.animation.easing.*;
import flash.animation.SyncTimer;
import flash.animation.AnimationEngine;
import flash.animation.AnimationEvent;
import flash.animation.IPlayable;
import flash.animation.PlayStates;
import flash.animation.BaseTween;
Sure, that's basically a suggestion that Adobe adopt the concepts behind GoASAP, why not? If they wanted to go all the way and make a statement in a Silverlight-tinged world, they would consider the creation of a standardized ECMA animation library that could be ported to AS3, JavaScript, and After Effects; however that's a different and much bigger proposal and one I've already made (see earlier posts at this blog). For now, simply by adding a centralized SyncTimer feature to the player and a few slim base classes, at least AS3 animation systems would share a common core instead of all having to reinvent the wheel.
Filed under: Go by mosesoak
1 Comment »