<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
                initialize="updateCar()" enterFrame="onEnterFrame()" 
                viewSourceURL="srcview/index.html" borderColor="#BBBBBB" borderStyle="solid" cornerRadius="4" backgroundColor="#FFFFFF">
    
    <mx:Script>
        <![CDATA[
            
            private var car:Car = new Car( new Point(150,150), -Math.PI/2);
            
            private function onEnterFrame():void
            {
                car.move();
                
                if(car.position.x < 0 || car.position.x > canvas.width
                    || car.position.y < 0 || car.position.y > canvas.height)
                    car.position = new Point(canvas.width/2, canvas.height/2);
                
                
                car.draw(canvas.graphics);
            }
            
            private function updateCar():void
            {
                car.speed = hs_speed.value;
                car.steering = hs_steering.value * -1;
            }
        ]]>
    </mx:Script>
    
    <!-- Canvas to draw the car on -->
    <mx:UIComponent id="canvas" width="100%" height="100%"/>
    
    
    <!-- Controls -->    
    <mx:Label x="10" y="10" text="Speed:"/>
    <mx:HSlider id="hs_speed" x="74" y="7" allowTrackClick="true" minimum="-10" maximum="10" snapInterval="0.1" liveDragging="true" value="2" change="{updateCar();}"/>
    
    <mx:Label x="10" y="36" text="Steering:"/>
    <mx:HSlider id="hs_steering" x="74" y="34" allowTrackClick="true" minimum="-1.2" maximum="1.2" snapInterval="0.1" value="-0.4" liveDragging="true" change="{updateCar();}"/>
    
    
    
</mx:Application>