<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundGradientColors="[#ffffff, #ffffff]" creationComplete="init()" viewSourceURL="srcview/index.html">

<mx:Script>
    <![CDATA[
        import com.acj.paperClasses.tools.DrawingTool;
        import com.acj.paperClasses.managers.DrawingToolManager;
        import com.acj.containers.BlankPaperWrapper;
        import mx.controls.SWFLoader;
    
        [Embed(source="Render2Front.swf")]
        public var render1:Class;
    
        [Embed(source="Render1.swf")]
        public var render2:Class;
    
        [Embed(source="Render3LHand.swf")]
        public var render3:Class;
        
        private var animatedSwf:SWFLoader;
        private var w:BlankPaperWrapper = new BlankPaperWrapper();
        private var tempTool:DrawingTool;
    
        private var timer:Timer = new Timer(650);
        
        private function init():void{
            timer.addEventListener(TimerEvent.TIMER, animationTimer);
            doStep1();
        }
        
        private function startAnimationTimer():void{
            timer.start();
        }
        
        private function animationTimer(event:TimerEvent):void{
            timer.reset();
            timer.stop();
            doStep3();
        }
        
        private function doStep1():void{
            myCanvas.removeAllChildren();
            DrawingToolManager.removeAllTools(w);
            
            var s:SWFLoader = new SWFLoader();
            s.source = render1;
            
            w.content = s;
            w.enableMouseInteraction = false;
            
            myCanvas.addChild(w);
            
            var sP:Point = new Point(325,250);
            var eP:Point = new Point(375,300);
            tempTool = w.createStaticTool(sP,eP);
            tempTool.addEventListener(MouseEvent.MOUSE_DOWN,onToolMouseDown);
            
        }
        
        private function onToolMouseDown(event:MouseEvent):void{
            DrawingToolManager.removeAllTools(w);
            removeToolListeners();
            doStep2();
            
        }
        
        private function removeToolListeners():void{
            tempTool.removeEventListener(MouseEvent.MOUSE_DOWN,onToolMouseDown);
        }
        
        private function doStep2():void{
            myCanvas.removeAllChildren();
            DrawingToolManager.removeAllTools(w);
            
            animatedSwf = new SWFLoader();
            animatedSwf.source = render2;

            w.content = animatedSwf;
            w.enableMouseInteraction = false;
            
            
            myCanvas.addChild(w);
            
            startAnimationTimer();
        }
        
        private function doStep3():void{
            var s:SWFLoader = new SWFLoader();
            s.source = render3;
            
            myCanvas.addChild(s);
        }
    ]]>
</mx:Script>
<mx:HBox x="0" y="0">
    <mx:Button label="Back to the Begining" click="doStep1()" />
</mx:HBox>
<mx:Text x="500" y="75"
    text="Click on the Rectangle in the image over the guys hand... and watch it animate... it's all just a trick... loading a different swf... right click to view the source" width="150" height="100"/>

<mx:Canvas id="myCanvas" x="0" y="30"/>
    
</mx:Application>