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

forked from: forked from: find it

Get Adobe Flash player
by tipein123 05 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/unrJ
 */

// forked from tipein123's forked from: find it
// forked from tipein123's find it
package {
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.utils.*;
    import flash.events.TimerEvent;

    
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..


var square:Sprite = new Sprite();
var Kreis:Sprite = new Sprite();
var Ziel:Sprite = new Sprite();
var ticker: Timer;

         square.graphics.beginFill(0xeeff00);
         square.graphics.drawRect(-50, -50, 100, 100);
         square.graphics.endFill();
         square.x = 150;
         square.y = 150;
         addChild(square);



         Ziel.graphics.lineStyle(2, 0x0066FF);
         Ziel.graphics.drawCircle(0, 0, 40);
         Ziel.x = 150;
         Ziel.y = 150;
         addChild(Ziel);

         Kreis.graphics.beginFill(0xee5533);
         Kreis.graphics.lineStyle(1, 0x66FF00);
         Kreis.graphics.drawCircle(0, 0, 25);
         Kreis.graphics.endFill();
         Kreis.x = 80;
         Kreis.y = 80;
         addChild(Kreis);

square.addEventListener(MouseEvent.CLICK, rotateM);

            ticker = new Timer(33);
            ticker.addEventListener(TimerEvent.TIMER, zielerfassung);
            ticker.start();


function zielerfassung(event:TimerEvent):void {
        square.rotation += 1;
        var xSchritt:int = 5;
        var ySchritt:int = 5;
        
       if (Math.abs(Kreis.x - Ziel.x) <= xSchritt)
        {
          if (Math.abs(Kreis.y - Ziel.y) <= ySchritt)
           {
             Kreis.x = Math.random()*500;
             xSchritt = int(Kreis.x / 10)
             Kreis.x = Kreis.x - Kreis.x%xSchritt;
             Kreis.y = Math.random()*500;
             ySchritt = int(Kreis.y / 10)
             Kreis.y = Kreis.y - Kreis.y%ySchritt;
           }
        }




        if (Kreis.x > Ziel.x)
        {
            Kreis.x -= xSchritt;
        }
        else if (Kreis.x < Ziel.x)
        {
            Kreis.x += xSchritt;
        }

        if (Kreis.y > Ziel.y)
        {
            Kreis.y -= ySchritt;
        }
        else if (Kreis.y < Ziel.y)
        {
            Kreis.y += ySchritt;
        }

        
}            

function rotateM(event:MouseEvent):void {
        square.rotation -= 15;
}            
            
    
        }
    }
}