forked from: Wonderfl本でお勉強 1-3 その2

by fakestar0826 forked from Wonderfl本でお勉強 1-3 その1 (diff: 46)
お前は基礎からやり直しじゃ!!
* ってな感じでやってきます。
* ボタン書いちゃう。描いちゃう。
♥0 | Line 44 | Modified 2010-04-16 12:51:37 | MIT License
play

ActionScript3 source code

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

/**
 * お前は基礎からやり直しじゃ!!
 * ってな感じでやってきます。
 * ボタン書いちゃう。描いちゃう。
 **/
package {
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import net.hires.debug.Stats;
    
    [SWF(width = "465", height = "465", frameRate = "60", backgroundColor = "#000000")]
    public class WonderflBook_1_3_2 extends Sprite {
    	
    	    public var button:DrawButton;
    	    
    	    
    	    public function WonderflBook_1_3_2() {
    	    	    button = new DrawButton(0xFF0000);
    	    	    
    	    	    
    	    	    addChild(button);
    	    	    
    	    	    button.addEventListener(MouseEvent.MOUSE_OVER, overHandler);
    	    	    button.addEventListener(MouseEvent.MOUSE_OUT, outHandler);
        	    
        }
        
        public function overHandler(e:MouseEvent):void {
        	    button.over();
        }
        
        public function outHandler(e:MouseEvent):void {
        	    button.out();
        }
        
    }
}

import flash.display.Sprite;
class DrawButton extends Sprite {
	private var _over:Sprite;
	public function DrawButton(color:uint) {
		graphics.beginFill(color);
    	    graphics.drawRoundRect(100,100,100,22,5);
    	    graphics.endFill();
    	    
    	    _over = new Sprite();
    	    _over.graphics.beginFill(0x0000FF);
    	    _over.graphics.drawRoundRect(100,100,100,22,5);
    	    _over.graphics.endFill();
    	    
    	    addChild(_over);
    	    _over.visible = false;
	}
	
	public function over():void {
		_over.visible = true;
	}
	
	public function out():void {
		_over.visible = false;
	}
}