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

code on 2008-12-19

Get Adobe Flash player
by ukot 22 Feb 2009
    Embed
package {
    import flash.display.Graphics;
    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.events.TimerEvent;
    import flash.geom.Point;
    import flash.utils.Timer;

    public class Anime1 extends Sprite
    {
        private var overFlag:Boolean = false;
        private var circleArray:Array = new Array();
        private var timer:Timer = new Timer(33);
        private var sp:Sprite = new Sprite();
        
        public function Anime1()
        {
            //var sp:Sprite = new Sprite();
            sp.graphics.lineStyle(10, 0x00aa00);
            sp.graphics.drawCircle(100, stage.stageHeight / 10, 20);
            addChild(sp);
            for (var i:int = 0; i < 10; i++) {
                circleArray.push(getCircle(180, 0x000000));
                addChild(circleArray[i]);
            }
            sp.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
            sp.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
            timer.addEventListener(TimerEvent.TIMER, anime);
            timer.start();
        }
        
        private function onMouseOver(event:MouseEvent):void {
            overFlag = true;
        }
        
        private function onMouseOut(event:MouseEvent):void {
            overFlag = false;
        }
        
        private function anime(event:TimerEvent):void {
            for (var i:int = 0; i < circleArray.length; i++) {
                var point:Point = new Point();
                if (overFlag) {
                    if (i == 0 || i % 5 == 0) {
                        point.x = sp.x - 40;
                        if (i == 0) {
                            point.y = sp.y;
                        }
                    } else {
                        point.x = circleArray[i - 1].x + 38;
                        point.y = circleArray[i - 1].y;
                    }
                } else {
                    if (i == 0 || i % 5 == 0) {
                        point.x = stage.stageWidth + 140;
                        point.y = stage.stageHeight / 2 - 140;
                    } else {
                        point.x = circleArray[i - 1].x;
                        point.y = circleArray[i - 1].y;
                    }
                }
                circleArray[i].x += (point.x - circleArray[i].x) / 6;
                circleArray[i].y += (point.y - circleArray[i].y) / 6;
            }
        }
        
        private function get g():Graphics{
            return graphics;
        }
        
        // 円のShapeを返す
        private function getCircle(pointX:int, 
             color:uint):Shape {
            var shape:Shape = new Shape();
            shape.graphics.lineStyle(10, color);
            shape.graphics.drawCircle(pointX, stage.stageHeight / 10, 20);
            return shape;
        }
    }
}