function() tricks and prototyping 101

by bradsedito forked from new function (diff: 96)
♥0 | Line 72 | Modified 2012-03-25 06:18:44 | MIT License
play

ActionScript3 source code

/**
 * Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/2XF7
 */





package
{
    import flash.utils.ObjectInput;
    import flash.geom.Orientation3D;
    import flash.geom.Vector3D;
    import flash.display.*
    import flash.events.*
    import flash.text.*
    import flash.ui.*
    import com.greensock.*
    import com.greensock.easing.*
    
    public class Main extends Sprite
    {
        public const SW:Number = stage.stageWidth
        public const SH:Number = stage.stageHeight
        private  var myTextField:TextField = new TextField()
        private  var DebugInfo:TextField = new TextField()
        private  var myObject:Object
        private  var myDebugObject:Object//:Orientation3D
        private  var extendedProps:Vector3D 
        public   var myWorld:Sprite
        
        
        public function Main():void
        {
            stage.addEventListener( Event.ENTER_FRAME,DebugApplicationRoot )
            // ENTRY POINT:  //////
            
            myWorld            =  new Sprite()
            myObject           =  new myFunction()
            myDebugObject      =  new DebugApplicationRoot()
            myTextField.text   =  myObject.str
            myTextField.width  =  SW 
            addChild( myTextField )
            
            DebugInfo.text     =  myDebugObject.debug_string
            DebugInfo.width    =  SW
            DebugInfo.x        =  10
            DebugInfo.y        =  SH/2
            addChild( DebugInfo )

            myWorld.x          =  0
            myWorld.y          =  0
            myWorld.z          =  0
            addChild( myWorld )
            
            /*myWorld.x         =  0
            myWorld.y         =  0
            myWorld.z         =  0
            *///addChild( aSprite )
            
            //addChild( myObject )
            //myWorld.addChild( myObject )
            //myWorld.w          =  0
                            
            extendedProps.prototype( myWorld,extendedProps )
            extendedProps.isPrototypeOf( myWorld )

            function RealTime( event:Event ):void
            {
                TweenMax.to( myWorld, 3, {ease:Quad.easeInOut})    
            }

            
            function myFunction():void  
            {
                this.str = "I write ActionScript"              +"\n"+
                           "...that writes ActionScript."      +"\n"
            }
            
            
            function DebugApplicationRoot():void
            {
                this.debug_string =
                ( 
                    "ObjectLocX:" + myWorld.x  + "\n" +
                    "ObjectLocY:" + myWorld.y  + "\n" +
                    "ObjectLocZ:" + myWorld.z            
                )
                
            }

            
            function extendedProps():Vector3D  
            {
                var locX:Number = this.x
                var locY:Number = this.y
                var locZ:Number = this.z
                var locW:Number = this.w
                var loc3D:Vector3D
                
                loc3D  =  new Vector3D( locX,locY,locZ,locW )                
                return loc3D    // trace( loc3D )
            }            
        }
        
        
    }
}