flash on 2014-1-29

by aiz
♥0 | Line 47 | Modified 2014-01-29 21:57:01 | MIT License
play

ActionScript3 source code

/**
 * Copyright aiz ( http://wonderfl.net/user/aiz )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/eIeh
 */

package{
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    public class MouseClick extends Sprite{
            private var _button:MyButton;
            public function MouseClick(){
                _button = new MyButton();
                _button.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
                _button.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
                addChild(_button);
                _button.x = 150;
                _button.y = 50;
            }
            private function onMouseOver(e:MouseEvent):void{
                _button.over();
            }
            private function onMouseOut(e:MouseEvent):void{
                _button.out();
            }
        }
}
import flash.events.MouseEvent;
import flash.display.Sprite;
class MyButton extends Sprite{
    private var _over:Sprite;
    public function MyButton(){
        graphics.beginFill(0x333333);
        graphics.drawRoundRect(0, 0, 100, 22, 15);
        graphics.endFill();
        _over = new Sprite();
        _over.graphics.beginFill(0xff0000);
        _over.graphics.drawRoundRect(0, 0, 100,22,15);
        _over.graphics.endFill();
        _over.visible = false;
        addChild(_over);
        buttonMode = true;
    }
    public function over():void{
        _over.visible = true;
    }
    public function mouseDownHandler(e:MouseEvent):void{
        e.currentTarget.start();
    }
    public function out():void{
        _over.visible = false;
    }

}