<?xml version="1.0"?>
<!-- draggingMain.mxml -->
<!-- (bouncing behaviour taken from [Peters, ActionScript 3.0 Animation])-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
    layout="absolute" creationComplete="init()" xmlns:ns1="*" 
    fontSize="16" resize="applicationResize();" viewSourceURL="srcview/index.html">
    
<mx:Script>
<![CDATA[          
    import mx.controls.Alert;
    private function about():void {
        Alert.show("This flash movie uses the component throwBall.mxml which " + 
                "implements acceleration, dragging and throwing. " + 
                "Right-click to view source. " +
                "(Ball dynamics from Keith Peters, " + 
                "'Foundation Actionscript 3.0 Animation: Making Things Move!' " + 
                "http://www.friendsofed.com/)", "About", Alert.OK);
    }  
    private var creationCompleted:Boolean=false;
    private var x1:Number, y1:Number, x2:Number, y2:Number, x3:Number, y3:Number;
    private function init():void {
        setIC();
        //addEventListener(Event.ENTER_FRAME, drawNextFrame);
        creationCompleted=true;
        applicationResize();
    }
    
    private function applicationResize():void{
        if(application.creationCompleted) {
            ball1.setBounceLimits(height, 0, 0, width);
            ball2.setBounceLimits(height, 0, 0, width);
            ball3.setBounceLimits(height, 0, 0, width);
        }
    }
    
    private function setIC():void {
        ball1.setInitialConditions(ball1.x, ball1.y, 10, -10);
        ball2.setInitialConditions(ball2.x, ball2.y, 5, +10);
        ball3.setInitialConditions(ball3.x, ball3.y, -12, +12);
    }
]]>
</mx:Script>    
    
    <mx:Text x="10" y="10" text="Mike Chantler's animation course: draggingMain.mxml"/>
    <ns1:throwBall x="231" y="112" id="ball1"/>
    <ns1:throwBall x="38" y="99" id="ball2" width="43" height="43"/>
    <ns1:throwBall x="97" y="233" id="ball3" width="30" height="30"/>
    <mx:Button x="10" y="42" label="About" click="about();"/>

</mx:Application>