In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

flash on 2012-1-29

Get Adobe Flash player
by tepe 29 Jan 2012
    Embed
/**
 * Copyright tepe ( http://wonderfl.net/user/tepe )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/wdgm
 */

package {
    import flash.display.*;
    import flash.geom.*;
    import flash.events.*;
    import flash.text.*;
    
    public class FlashTest extends Sprite {
        private var p:Point = new Point(200,200);
        private var mp:Point = new Point(mouseX,mouseY);
        private var s:Sprite = new Sprite();
        private var line:Shape = new Shape();
        private var txt1:TextField = new TextField();
        private var s2:Sprite = new Sprite();
        private var state:String = new String();
        public function FlashTest() {
            // write as3 code here..
            
            s.graphics.beginFill(0x00ff00);
            s.x = p.x;
            s.y = p.y;
            s.graphics.drawCircle(0,0,50);
            s.graphics.endFill();
            addChild(s);
            s2.graphics.beginFill(0x0000ff);
            s2.graphics.drawRect(0,0,100,100);
            s2.graphics.endFill();
            addChild(s2);
            
            s.addChild(line);
            addEventListener(Event.ENTER_FRAME,onEnter);
            txt1.text = "aa";
            addChild(txt1);
            stage.addEventListener(MouseEvent.MOUSE_OVER,overMouse);
            stage.addEventListener(MouseEvent.MOUSE_OUT,outMouse);
            stage.addEventListener(Event.MOUSE_LEAVE,leave);
            
        }
        
        private function overMouse(e:MouseEvent):void{
            state = "overMouse";
        }
        private function outMouse(e:MouseEvent):void{
            state = "outMouse";
        }
        private function leave(e:Event):void{
            state = "mouseLeave";
        }



        
        private function onEnter(e:Event):void{
            mp.x = mouseX; mp.y = mouseY;
            
            var n:Number = Point.distance(p, mp);
            var vector:Point = mp.subtract(p);
            //vector=(x=290,y=380)
            var angle:Number = Math.atan2(vector.y,vector.x);
            var pt1:Point;
            
            
            if(50<n){
                s.graphics.clear();
                s.graphics.beginFill(0xff0000);
                s.graphics.drawCircle(0,0,50);
                s.graphics.endFill();
                pt1 = Point.polar(n-50,angle);
                s2.x -=pt1.x/100; s2.y -=pt1.y/100;
            }
            else{
                s.graphics.clear();
                s.graphics.beginFill(0x00ff00);
                s.graphics.drawCircle(0,0,50);
                s.graphics.endFill();
            }

 

            line.graphics.clear();
            line.graphics.lineStyle(0,0x000000,0.5);
            line.graphics.moveTo(0,0);
            line.graphics.lineTo(pt1.x,pt1.y);
            txt1.text = n.toString();
            txt1.appendText("\n"+state);
        }

    }
}