forked from: FIO Basic Example: LED arduino

by azuremous forked from FIO Basic Example: LED (diff: 37)
画面上のボタンを押すとFIOボード上のD13に接続されたLEDが点灯し、
ボタンを離すとボード上もLEDが消灯します
Reference
http://funnel.cc/Main/GettingStarted
http://funnel.cc/Hardware/FIO
♥0 | Line 38 | Modified 2010-02-26 15:57:35 | MIT License
play

ActionScript3 source code

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

// forked from kotobuki's FIO Basic Example: LED
// forked from kotobuki's Gainer Basic Example: LED
// 画面上のボタンを押すとFIOボード上のD13に接続されたLEDが点灯し、
// ボタンを離すとボード上もLEDが消灯します
// 
// Reference
// http://funnel.cc/Main/GettingStarted
// http://funnel.cc/Hardware/FIO

package {
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    
    import funnel.*;
    import funnel.ui.*;

    public class GainerBasic_LED extends Sprite {
        //private var fio:Fio;
        private var arduino:Arduino;
        //private var led:LED;

        private var squareButton:Sprite;

        public function GainerBasic_LED() {
            //var config:Configuration = Fio.FIRMATA;
           // fio = new Fio([1], config);
            arduino = new Arduino;
            var config:Configuration = Arduino.FIRMATA;
            config.setDigitalPinMode(11, OUT);
            var onBoardLED:Pin = arduino.digitalPin(11);
            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;
            squareButton.buttonMode = true;
            this.addChild(squareButton);

           // led = new LED(arduino.digitalPin(12));
            //squareButton.addEventListener(MouseEvent.MOUSE_DOWN, mousePressed);
            squareButton.addEventListener(MouseEvent.MOUSE_DOWN, 
            function mousePressed(e:MouseEvent):void {
           // led.on();
       //   led.value = 1.0;
            onBoardLED.value = 1.0;
            squareButton.scaleX = 1.2;
            squareButton.scaleY = 1.2;
        }
            );
          //  squareButton.addEventListener(MouseEvent.MOUSE_UP, mouseReleased);
            squareButton.addEventListener(MouseEvent.MOUSE_UP, 
            
            function mouseReleased(e:MouseEvent):void {
          //  led.value = 0.0;
            onBoardLED.value = 0.0;
            squareButton.scaleX = 1.0;
            squareButton.scaleY = 1.0;
        }
            );
        }
/*
        private function mousePressed(e:MouseEvent):void {
           // led.on();
       //   led.value = 1.0;
           //onBoardLED.value = 1.0;
            squareButton.scaleX = 1.2;
            squareButton.scaleY = 1.2;
        }

        private function mouseReleased(e:MouseEvent):void {
          //  led.value = 0.0;
            squareButton.scaleX = 1.0;
            squareButton.scaleY = 1.0;
        }*/
    }
}

Forked