PackageDescription: ExtraActivity

Extra Activity

Last published: April 5, 2013 by 'tgriggs'

Defines 2 Classes
Extends 5 Classes

ExtraActivity adds a framework to VisualParts intended to make them easier to animate. Any VisualPart can respond to the following messages:

#startActivityRate: aRateInHz
This message is uses to begin recieving periodic ticks with which any sort of work can be done, usually some sort of check for state change and redraw as appropriate

#activityTickEvent: aTickEvent
This is the message you override in your subclass. You do your periodic work in here. Two important messages that aTickEvent respond to are #time and #deltaTime. #time acts as it does with all over events, the time according to the system micro clock that this event was initiated. #deltaTime returns the time in floating point seconds that has elapsed since the last time you recieved an event via this mechanism.

Shut down activity for this VisualPart. May be called redundantly.

Returns whether ticking is currently occuring, usually used as a guard clause if your using a trigger point such as displayOn: to start ticking.

A view will only tick when it has a topComponent. When it doesn't ticking will be automatically shut down. Since tick events are serialized along the same event queue that other events occur, you don't have to worry about race conditions (e.g. a window closure pulling your GC out from under you). Also, the system is GC savvy. When your view is collected, any associated ticking overhead will be GC'ed as well.

Look at the ClockExample class for an example.
ExtraActivity was written by Travis Griggs while at Key Technology. Much thanks to his teammates who used it and helped find bugs, and special thanks to Anthony Lander for helping evolve and critique the original design.