Home >
A Reflection on AS2 and Timeline Development
This past weekend I assisted my director at my university with a project he was working on for the president of the school. It was a fun project, and the time line was essentially by the end of the weekend so we ended up hanging out and coding a good chunk of Saturday and well into the night on Sunday. What was most interesting to me about the project was that it was my first opportunity in several years to actually code in ActionScript 2.0 again, and it caused me to reflect on what I see as the main core difference is.
Beyond any of the obvious syntactical differences which are superficial and easily picked up, there is a methodology difference, specifically the time line and MovieClips. If you look at the code of a developer who recently migrated from AS2 to AS3 you might notice that they tend to inherit from MovieClip for all or almost all of their classes. Maybe they use the MovieClip inheritance to get access to the time line. Maybe they are using Flash for most of their development.
When I teach AS3 the first thing I do is have my students install Eclipse with the FlexBuilder plug in and I bar Flash from being used in that class room. It's a complete break from the timeline and timeline way of thinking. It's going cold turkey for students that were previously only familiar with AS2.
Going back to AS2 in Flash this weekend was definitely an interesting exercise. I found the syntactical differences to not be an issue - aside from having to remember to keep adding underscores for properties. What I found to be the most interesting thing was revisiting the concept of timeline scope variables.
In AS3 I'd gotten used to using [BINDABLE] on my setters to be able to set properties of dynamically created objects. I had almost forgotten the pain that I had to go through in AS2 when I would create a MovieClip dynamically in a loop and try to set timeline variables. In fact that was the one solution that I implemented a hack for, the entire weekend. Considering the time line for the project I consider that an accomplishment.
For the record my hack solution was to create a multidimensional array that contained the MovieClip name associated with the values that I wanted to set. I then ran a check at a later date to loop through the array and when I found the name of the current MovieClip I then pulled the values from the array and set them in the MovieClip.
Another odd thing that I had to do was to create a timeline variable on frame 1, then populate it dynamically on frame 31, so that I could reference and update it from a behavior attached to a MovieClip that existed on frame 30 to 35.
As I prepare to teach AS3 to a new batch of students after winter break on, it was good to refresh myself on some of the acrobatics that were necessary specifically with timeline development and to remind myself why I moved my students away from the timeline in the first place.




Facebook Application Development
Question - do you think its valuable for a developer who came to Flash via Flex / Eclipse to educate himself on timeline development? Every time I've opened Flash CS3 and tried to start a project the traditional way I get frustrated pretty quickly. I know this is contrary to how probably 90% of the Flash community is (most learning traditional Flash first and maybe struggling to move to AS3 / Flex) but I'm wondering if there are advantages to using pure Flash for some projects.
I'm mostly developing RIA's with some small design projects as well which I usually just do in Flex Builder.
@nylarch - I see no benefits to learning timeline based development. In my opinion it's taking a step backwards. I hope I illustrated just some of the hoops you have to jump through sometimes with timeline based development that you no longer have to worry about when you embrace AS3 and use it the way it's intended to be used - object oriented and event driven.
The most similar feature of AS2 to [Bindable] is Object.watch, still painful but might do the job sometimes.