Updates to Car Example (Interface and ASDoc Comments)
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
[as]
public class Car extends Image
[/as]
Object composition
Car contains Engine,Tires, and Steeringwheel
[as]
public function Car()
{
super();
_engine = new Engine();
_steeringWheel = new SteeringWheel();
_tires = new Array();
_tires.push( new Tire( “RearLeft” ) );
_tires.push( new Tire( “RearRight” ) );
_tires.push( new Tire( “FrontLeft” ) );
_tires.push( new Tire( “FrontRight” ) );
}
[/as]
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
[as]
parentObject.dispatchEvent( new CarMonitorEvent( “Engine started” ) );
[/as]
Getter/Setters
[as]
public function set parentObject( value:UIComponent ):void {
_parentObject = value;
}
public function get parentObject():UIComponent {
return _parentObject;
}
[/as]
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
Recent Comments