mike chambers | about

Branden Hall Session 1 of 3.

The first day of Flash Forward involves a number of half day sessions / classes. I am sitting in Branden Hall’s first session of three. The first session is on Object Oriented Programming in Flash (something that Branden and Sam Wan just wrote a book on).

Branden is discussing some of the basics of Object oriented programming in Flash, including objects vs instances, and how to create custom classes.
Importance of encapsulation

Composition vs Inheritance

Branden says that Generally you should avoid inheritance (i don’t agree with this, and Branden and i got into a pretty heated discussion about it on the train-mc). Inheritance in Flash can be messy.
You should consider using composition instead of inheritance. Composition is a “has a” relationship. Inhiritance is a “is a” relationship.

Design Patterns

3 patterns
Value Object Pattern : don’t use multiple getter / setter methods. multiple function calls can cause performance issues, especially for remote methods. Send a value / object which contains properties and values. Only requires one method call, and properties can be set at once: foo.setValues({name:“mike”, address:“500 main st.”});

Observer Pattern : Multiple events need to listen for events from a single object. The event source object allows other objects to add or remove themselves as listeners.
Easiest way is to use undocumented AsBroadcaster

FooClass = function(){ AsBroadcaster.initialize(this);}
FooClass.prototype.sendEvent = function(){this.broadcastMessage("onEvent");}
myFoo = new Foo();
myFoo.addListener(this);

See flash coders wiki for more info.

Model / View Controller Pattern : Some articles at Des / Dev Center.

Branden is showing a new app called bibliofile that he uses to keep track of all of his books. uses treemenu component, and new tabbed view component that branden built. Showing some of the listener code in the model section of the application. Uses value object pattern to pass properties / values into objects. the app has multiple frames, which each frame representing a different state of his application. The app uses Flash Remoting to get information on books from a remote web service.
TabBar component : Branden is very happy with this, he feels he hit the “sweet spot” with it (not over or under engineering it). Live preview, scalling. You add tabs through PI and set alignment, and then when the tabs are clicked, callback methods are called where you can have code that reacts to the event. In the case of brandens app, it either moves between frames, or hides movie clips (he is using it in two places).

ToolTip component : Drag and drop, add message in PI. Super easy to use.

KeyBoard Navigation Component. Isn’t showing it because he didnt have time to get it in the session.
end of first hour, next hour is about components and working with flash remoting.

twitter github flickr behance