Articles

Tag Archive for 'movieclip'

FramescriptManager: insert code on your timeline at runtime

In an earlier post we showed you how to seperate design and code by keeping code off the timeline at all times. The method was to have designers add framelabels to the movieclips’ timeline and have the developers react to the flash playhead reaching this framelable by means of an Event. This created a clean seperation between the job of coders and the job of designers.

We used the TimelineListener class as an example in that earlier post. This post will show you how to take an alternative approach, without event listeners, but by means of injecting code in a frame at runtime by means of our FrameScriptManager and the MovieClip.addFramescript method.
Continue reading ‘FramescriptManager: insert code on your timeline at runtime’

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’