When working with animation need to insert code into specific frames
I will use my latest project – Asset Modifier
I have created project called Asset Modifier that adds a simple way for both - programmer and animator, how to add a code into animations. The idea of project is very simple, animator uses a special frame labels in animations, where must be a code. And programmer uses Asset Modifier project to insert code into marked frames.
[Embed(source='../asset.swf', symbol='Asset')]
static public const ASET_DEFINITION:Class;
protected function initialize():void{
var asset:MovieClip = new ASET_DEFINITION();
ModifierManager.apply(asset);
asset.x = 100;
asset.y = 100;
this.addChild(asset);
}
Only one line of code for asset, to inject code - ModifierManager will search for marked labels and inject code into these frames.
How it knows, where is just a frame label or special frame label that can be used? Label must start from mark symbol, by default it is a dot, for example ".event" or ".stop". Project has core actions (in project called "modifiers") that can be used from start:
• .stop - stops animation
• .event - dispatches an event
• .breakpoint - makes breakpoint for debug mode
• .goto - go to frame and continue playing or stop
• .trace - trace something, can parse native AS3 commands, for example you can set label like ".trace(this.name, this.getBounds(this))"
Some actions can use extended syntax with parameters in braces, for example .event action can be labeled like:
.event(eventType)
.event(type="change", event="flash.events.Event")
.event(type="custom", event=flash.events.Event, anyParam="any value")
.event(type="someEvent", event=flash.events.Event, bubbles=false, cancelable=false, additionalParam="some value")
Developers can use global modifier manager with all registered actions, create own instances with specific list of actions and custom frame label marker and extend Asset Modifier with own actions, use multi-action labels.
Also project contains special AssetConstructor classes, that contains Asset Modifier instance and definition of embedded asset, that can be used to automatically create asset and "patch" it with registered actions.
More info about project you can find on projects page, download examples, SWC and source.
+