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

forked from: Gainer Basic Example: External Button with Timer

din 0に接続したボタンを押す、離す、長押しすると画面上の
矩形が変化します。ボタンを押した間隔も左上に表示します。
基本的なセットアップについては以下のURLを参照してください
http://funnel.cc/Main/GettingStarted
/**
 * Copyright sei_lowtech ( http://wonderfl.net/user/sei_lowtech )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/8I3W
 */

// forked from kotobuki's Gainer Basic Example: External Button with Timer
// forked from kotobuki's Gainer Basic Example: External Button
// forked from kotobuki's Gainer Basic Example: Button
// din 0に接続したボタンを押す、離す、長押しすると画面上の
// 矩形が変化します。ボタンを押した間隔も左上に表示します。
// 
// 基本的なセットアップについては以下のURLを参照してください
// http://funnel.cc/Main/GettingStarted

package {
    import flash.display.Sprite;
    import funnel.*;
    import funnel.gui.*;
    import funnel.ui.*;
    import flash.utils.getTimer;
    import flash.text.*

    public class GainerBasic_Button extends Sprite {

        private var gio:Gainer;
        private var button0:Button;
        private var button1:Button;
        private var button2:Button;
        private var button3:Button;

        private var squareButton:Sprite;
        
        private var switch0:Number = 0;
        private var switch3:Number = 0;

  
 
          
        private var lastPress:Number = 0;
        private var textField:TextField;
        

        public function GainerBasic_Button() {
            gio = new Gainer();

            squareButton = new Sprite();
            squareButton.graphics.beginFill(0x808080);
            squareButton.graphics.drawRect(-25, -25, 50, 50);
            squareButton.graphics.endFill();
            squareButton.x = stage.stageWidth / 2;
            squareButton.y = stage.stageHeight / 2;
            this.addChild(squareButton);

            var gui:GainerGUI = new GainerGUI();
            addChild(gui);
            gio.gui = gui;

            textField = new TextField();
            addChild(textField);
            
            button0 = new Button(gio.digitalInput(0));
            button1 = new Button(gio.digitalInput(1));
            button2 = new Button(gio.digitalInput(3));
            button3 = new Button(gio.digitalInput(3));
            
            button0.addEventListener(ButtonEvent.PRESS, buttonPressed);
            button1.addEventListener(ButtonEvent.PRESS, buttonPressed);
            button2.addEventListener(ButtonEvent.PRESS, buttonPressed);
            button3.addEventListener(ButtonEvent.PRESS, buttonPressed);
                      
        }

        private function buttonPressed(e:ButtonEvent):void {
            if (gio.digitalInput(0).value == 1 && gio.digitalInput(1).value == 0 && gio.digitalInput(2).value == 0 && gio.digitalInput(3).value == 0) {
                textField.text = "あ";
            } else if(gio.digitalInput(0).value == 0 && gio.digitalInput(1).value == 1 && gio.digitalInput(2).value == 0 && gio.digitalInput(3).value == 0){ 
                textField.text = "い";
            } else if(gio.digitalInput(0).value == 0 && gio.digitalInput(1).value == 0 && gio.digitalInput(2).value == 1 && gio.digitalInput(3).value == 1){ 
                textField.text = "う";
            } else if(gio.digitalInput(0).value == 0 && gio.digitalInput(1).value == 0 && gio.digitalInput(2).value == 0 && gio.digitalInput(3).value == 1){ 
                textField.text = "え";
            } else textField.text ="---";
            }
}  
}