Updates to Car Example (Interface and ASDoc Comments)

July 13th, 2006

The Flex object composition car example I recently created got some updates. I changed CompositionBase into a interface instead inheriting the class (thx Marcus for the heads up on that one). I also went through all the code and style the source code just like the Flex source. You find the code with ASDoc compliment comments and Flex styled sections.

With these updates the set of Car examples classes provide the following benefits:
Object inheritance

Actionscript:
  1. public class Car extends Image

Object composition
Car contains Engine,Tires, and Steeringwheel

Actionscript:
  1. public function Car()
  2. {
  3. super();
  4. _engine = new Engine();
  5. _steeringWheel = new SteeringWheel();
  6. _tires = new Array();
  7. _tires.push( new Tire( "RearLeft" ) );
  8. _tires.push( new Tire( "RearRight" ) );
  9. _tires.push( new Tire( "FrontLeft" ) );
  10. _tires.push( new Tire( "FrontRight" ) );
  11. }

Interfaces - Engine,Tires, and SteeringWheel implement CompositionBase

ASDoc comments - Seen in the use of /** @public .... */ styled comments

Adobe Flex source code section style - Seen in the use of //-------- styled comments to break up "Constructor", "Variables", "Properties", "Methods", and other specific section styled blocks

Custome Event - CarMonitorEvent

Dispatching Events

Actionscript:
  1. parentObject.dispatchEvent( new CarMonitorEvent( "Engine started" ) );

Getter/Setters

Actionscript:
  1. public function set parentObject( value:UIComponent ):void {
  2. _parentObject = value;
  3. }
  4. public function get parentObject():UIComponent {
  5. return _parentObject;
  6. }

There are probably more but thats good enough for the highlights.

For the full code example click here.

You can view the source here.

Object Composition versus Inheritanance and other good reading:
Composition versus Inheritanance
Object composition

Entry Filed under: Adobe Flex, Rich Internet Applications

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Disclaimer: I work as a Flash/Flex Developer for Adobe Systems Incorporated. The opinions expressed here represent my own and not those of my employer.

My Amazon.com Wish List

Calendar

July 2006
S M T W T F S
« Jun   Aug »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Most Recent Posts


Flex.org - The Directory for Flex