TK Event Engine F5 v1.35
Another event engine for ActionScript

Download the source fla

== What's an event engine? ==

The blank movieclip called "eventEngine" put on the stage of the source fla is the event engine of TK Event Engine.

Movieclips' event handlers such as onClipEvent(enterFrame) or onClipEvent(mouseDown) trigger what you told them to do when the corresponding events, which are either system events (i.e. load or enterFrame) or user events (i.e. mouseUp, mouseDown, mouseMove, keyUp or keyDown), occur.

What you can do with an event engine is to make movieclips do what you want them to do without writing anything on the movieclips themselves, responding to those events as if onClipEvents were written on them.

== Why an event engine? ==

To achieve things such as:

- Separation of code and artwork, which makes it easier to hunt the code you look for, to replace the artwork, to re-use the code, etc.

- Being able to assign what to do to movieclips/objects on the fly.

- Being able to make attachMovie'd movieclips do something as if you would write onClipEvents on them, which usually can't be done unless you have them nested in parent movieclips.

- Being able to have a group that responds to an assigned virtual event.

== What's an event listener? ==

A movieclip or an object that is on stand-by waiting for the event it's been subscribed to to occur.

== Syntax ==

To subscribe an event listener
eventEngine.subscribe(sEvent, sPathToMethod, oArgs);

To unsubscribe an event listener
eventEngine.remove(sEvent, sPathToMethod);

== Usage examples ==

Subscribe _root.myObj.myFunc with an arguments object {num: 5, str: "hello"} to enterFrame
eventEngine.subscribe("enterFrame", "_root.myObj.myFunc", {num: 5, str: "hello"});

Unsubscribe _root.myObj.myFunc from enterFrame
eventEngine.remove("enterFrame", "_root.myObj.myFunc");

Unsubscribe all the event listeners of enterFrame
delete eventEngine.enterFrame;

Manually execute (in other words, send a virtual event to) all the listeners of mouseDown

Subscribe _root.textFieldMC1.clear with no arguments to a virtual event "allClear"
eventEngine.subscribe("allClear", "_root.textfieldMC1.clear");

Send a virtual event to all the listeners of allClear

== What the arguments to pass to the method "subscribe" should look like ==

An example of sEvent :


An example of sPathToMethod :


Note: This should be a string of the absolute path to the method via the movieclip/object. To make it so, getting the absolute path of the timeline by targetPath(this) will be helpful at times, especially when the timeline is unknown.
eg: targetPath(this) + ".myFunc"

An example of oArgs :

{num: 5, str: "hello"}

Note: This is optional. And if there's only one argument to pass, no need to use an object literal.(i.e. You can just pass the value alone)

Demonstration swf

Back to Flash Home

Copyright©2000-2002 STUDIO FIRST RAYS. All rights reserved