Articles

Monthly Archive for March, 2009

Timeline Events via the TimelineListener class

While viewing a post on bytearray.org and after teaching a class on creative technology at the avans hogeschool today, I got inspired to write some easy code to be informed by the timeline of a Movieclip when a certain label is reached.

A student of mine slapped me in the face with my own words that “code on the timeline is evil” when he asked how he could trigger an action inside the flash Document Class from the timeline or from a specific framelabel. My reply was simple: just call a method on a certain keyframe that you have exposed in the Document class. < Sssslappppp > :) So I decided to show him the clean way by listening to an Event.ENTER_FRAME Event and checking the framelabel or the end of the timeline whenever the event handler got called. All from inside the Document class, no code on the timeline there.

I encapsulated the whole thing in a class, have it dispatch events you can register to and make it able to get some data out of it and at the same time make it work for different scenes (as he was working with them). In this way we can perfectly seperate design and timeline stuff from code, optimizing workflow by having designers tweak their animations and killer design while only informing the developer of some framelabels and eliminating spaghetti code and potential bugs.

For this purpose I wrote the TimelineListener class in the nl.dpdk.utils package. read on for some simple code.
Continue reading ‘Timeline Events via the TimelineListener class’

Factory for creating ResultSet from an SQLResult in AIR

There is a minor update in the nl.dpdk.air package.

While creating some AIR applications, it turned out the SQLResult, a resultset wrapper used when working with a local SQLite database is not as powerful as we want it to be. Therefore we wrote a little Factory to convert an SQLResult to an nl.dpdk.collections.sets.ResultSet.

Our ResultSet is also used when doing flash remoting and when returning data from a remote database, (see the post about that here).
So it’s convenient to use when working with local data from a database as well. As an added bonus, it offers some more features than the very simple SQLResult, which is essentially an Array of anonymous objects.

The ResultSet makes use of our very powerful List datastructure, which features sorting (which is better done by the database), selecting, mapping, folding and applying commands as well as a very rich api where you can use the datastructure as a Queue or a Stack.
Continue reading ‘Factory for creating ResultSet from an SQLResult in AIR’