// mxmlc -output ./bin/ReadButton.swf -benchmark=true -default-frame-rate=60 ReadButton.as

package {
    import flash.display.*;
    import flash.text.*;
    import flash.events.*;

    [SWF(backgroundColor=0x000000, width=240, height=240)]

    public class ReadButton extends Sprite {

        [Embed(source='RotButton.swf')]
        private var SwfButton:Class;

        private var textField:TextField;
        public var testButton :SimpleButton;

        public function ReadButton() {

            var base:Sprite = new Sprite();
            base.graphics.beginFill(0x000000);
            base.graphics.drawRect(0,0,240,240);
            base.graphics.endFill();
            addChild(base);

            textField=new TextField();
            textField.text="ボタン読み込みサンプル";
            textField.textColor = 0xffffff;
            textField.x = 10;
            textField.y = 10;
            base.addChild(textField);

            var but:Sprite = new SwfButton();
            but.x = (240-but.width)/2;
            but.y = (240-but.height)/2;
            but.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
            but.addEventListener(MouseEvent.MOUSE_UP,mouseUpHandler);
            but.addEventListener(MouseEvent.MOUSE_OVER,mouseOverHandler);
            but.addEventListener(MouseEvent.MOUSE_OUT,mouseOutHandler);
            base.addChild( but );


        }

        private function mouseDownHandler(event:MouseEvent):void
        {
            textField.text = "ダウン";
        }
        private function mouseUpHandler(evt:MouseEvent):void {
            textField.text = "アップ";
        }
        private function mouseOverHandler(evt:MouseEvent):void {
            textField.text = "オーバー";
        }
        private function mouseOutHandler(evt:MouseEvent):void {
            textField.text = "アウト";
        }


    }
}