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 2010-9-1

Get Adobe Flash player
by Tamanegi_kenshi 01 Sep 2010
    Embed
/**
 * Copyright Tamanegi_kenshi ( http://wonderfl.net/user/Tamanegi_kenshi )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/wxae
 */

package {
    import flash.events.MouseEvent;
    import flash.display.AVM1Movie;
    import flash.display.Sprite;
    import flash.events.Event;
    
    public class FlashTest extends Sprite {
        private var head:Head;
        private var lefthand:Hand;
        private var righthand:Hand;
        private var body:Body;
        private var leftfoot:Foot;
        private var rigthfoot:Foot;
         
        private var ax:Number = 0;
        private var ay:Number = 0; 
        private var vx:Number = 0;
        private var vy:Number = 0;
        
        private var isRakka:Boolean = false;
        
        public function FlashTest() {
            init();
        }
        private function init():void{
            man(100, 300);
            
            
            
        }
        
        private function man(headX:int, headY:int):void{
            lefthand = new Hand();
            lefthand.rotation = 45;
            addChild(lefthand);
            righthand = new Hand();
            righthand.rotation = -45;
            addChild(righthand);
            body = new Body();
            addChild(body);
            leftfoot = new Foot();
            addChild(leftfoot);
            rigthfoot = new Foot();
            addChild(rigthfoot);
            head = new Head();
            addChild(head);
            head.x = headX;
            head.y = headY;
            
            addEventListener(Event.ENTER_FRAME, onEnter);
          //  stage.addEventListener(MouseEvent.CLICK, onClick);
            head.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
            head.addEventListener(MouseEvent.MOUSE_UP, onUp);
        }

        
        private function onDown(e:MouseEvent):void{
            head.startDrag();
            isRakka = false;
        }
        private function onUp(e:MouseEvent):void{
            head.stopDrag();
            isRakka = true;
            
        }


        private function onClick(e:MouseEvent):void{
            if(isRakka == false){
                isRakka = true;
            }else{
                isRakka = false
            }


        }

        private function onEnter(e:Event):void{
          
            if(isRakka == false){
        //    test(head, mouseX, mouseY + 50, 0.3);
            test(body, head.x, head.y + 20, 0.4);
            test(leftfoot, body.x - 7, body.y + 20, 0.2);
            test(rigthfoot, body.x + 7, body.y + 20, 0.2);
            test(lefthand, body.x - 7, body.y + 10, 0.2);
            test(righthand, body.x + 7, body.y + 10, 0.2);
            }else{
            rakka();
            }
        }
        private function test(ball:Sprite, targetX:Number, targetY:Number, spring:Number):void{
            vx +=(targetX - ball.x) * spring;
            vy +=(targetY - ball.y) * spring;
            vx *= 0.8;
            vy *= 0.8;
            
            ball.x += vx;
            ball.y += vy;
        }

     
        private function rakka():void{
            head.y += 20;
            body.y += 20;
            lefthand.y += 20;
            righthand.y += 20;
            leftfoot.y += 20;
            rigthfoot.y += 20;
            if(head.y >= 465){
                head.y = 465;
                body.y = 465;
                lefthand.y = 465;
                righthand.y = 465;
                leftfoot.y = 465;
                rigthfoot.y  = 465;
            }
        }




    }
}


import flash.display.Sprite;
class Head extends Sprite{
    function Head(){
        graphics.beginFill(0x000000);
        graphics.drawCircle(0, 0, 30);
        graphics.endFill();
    }
}
import flash.display.Sprite;
class Body extends Sprite{
    function Body(){
        graphics.beginFill(0x000000);
        graphics.drawRect(-10, -10, 20, 35);
        graphics.endFill();
    }
}
import flash.display.Sprite;
class Hand extends Sprite{
    function Hand(){
        graphics.beginFill(0x000000);
        graphics.drawRect(-2.5, -15, 5, 30);
        graphics.endFill();
    }
}
import flash.display.Sprite;
class Foot extends Sprite{
    function Foot(){
        graphics.beginFill(0x000000);
        graphics.drawRect(-2.5, -15, 5, 30);
        graphics.endFill();
    }
}