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 2011-1-17

Get Adobe Flash player
by tipein123 16 Jan 2011
    Embed
/**
 * Copyright tipein123 ( http://wonderfl.net/user/tipein123 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/ecFW
 */

package {
    import flash.display.*;
    import flash.geom.*;
    
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            var Ziel:Point = new Point(stage.stageWidth/2,stage.stageHeight/2);
            var Komet:Point = new Point(Math.random()*stage.stageWidth,Math.random()*stage.stageHeight);
            
            var Welt:Sprite = new Sprite();
            addChild(Welt);
            
            Welt.graphics.lineStyle(0,0xff0000); 
            Welt.graphics.drawCircle(Ziel.x,Ziel.y,20);
            Welt.graphics.lineStyle(0,0x0000ff); 
            Welt.graphics.drawCircle(Komet.x,Komet.y,5);  
            
            var wohin:Array = holeNeuenPunkt(Komet.x,Komet.y);
            
            Welt.graphics.lineStyle(0,0xcccccc); 
            Welt.graphics.moveTo(Ziel.x,Ziel.y);
            Welt.graphics.lineTo(wohin[0],wohin[1]);
            
            
            
            function holeNeuenPunkt(nPx:Number , nPy:Number):Array{
                var Winkel:Number;
                var Ausgabe:Array;
                var Laenge:Number = Math.sqrt( (nPx-Ziel.x)*(nPx-Ziel.x) + (nPy-Ziel.y) * (nPy-Ziel.y) );
                Laenge = Laenge * 0.99;
                 
                Winkel = Math.atan2 ((nPx - Ziel.x), (nPy - Ziel.y));
                Winkel = Winkel + (Math.PI/180)*2; 
                Ausgabe = [ Ziel.x + (Math.sin(Winkel)*Laenge) , Ziel.y + (Math.cos(Winkel)*Laenge) ];

                return Ausgabe; 
            } 

            
        }
    }
}