5

Branden Hall’s Session 1 of 3.

 3 years ago
source link: http://www.mikechambers.com/blog/2002/07/10/branden-halls-session-1-of-3/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Branden Hall’s Session 1 of 3.

Wednesday, July 10, 2002

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

  • Using getter / setter methods to access internal properties.
  • Should not directly access internal object properties.
  • Don’t hard code references to timelines (if they are needed, pass them in through a method).
  • many getter / setter methods can inidcate design problems.</UL>

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

  • Take advantage of previous work that has already solved common problems.
  • Object oriented and language independent (any design patter book can be applied to flash).</UL>

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.

  • Seperate data from presentation.
  • Model : Data
  • View : Interface
  • Controller “ Logic
  • All pieces are independent of one another, although code for pieces are often all combined in one place in flash (on main timlines). *just make sure to comment the different sections-mc. *
  • Sections can be swapped out and changed without affecting other layers. (i.e. switch out view to create new interface for different devices / platforms).
  • Model View Presenter (more advanced).
  • This architeture works very well for creating applications in Flash.
  • Layers should be completely independent of each other.
  • Model should be abstracted away from viewer and controller (it should not know about them).
  • The view listens for events.</UL>

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.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK