This repository was archived by the owner on Feb 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
DawnBasics
digitalally edited this page Sep 13, 2010
·
17 revisions
We want a car, and a car needs an engine (sadly):
class Car {
private var engine:LittleEngine;
public function Car(engine:LittleEngine){
this.engine = engine;
}
public function startCar():void {
engine.start();
}
}
<?xml version="1.0" encoding="utf-8"?>
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
minWidth="1024" minHeight="768"
creationComplete="creationCompleteHandler(event)">
<fx:Script>
<![CDATA[
import uk.co.ziazoo.injector.IInjector;
import uk.co.ziazoo.injector.impl.Injector;
import mx.events.FlexEvent;
protected function creationCompleteHandler(event:FlexEvent):void {
var injector:IInjector = Injector.createInjector()
var car:Car = Car( injector.inject( Car ) );
car.startCar();
}
]]>
</fx:Script>
</s:Application>
Job done… Dawn created our Car, with its LittleEngine… it gets more exciting later on, I promise.