forked from: Gainer Basic Example: Analog Input with Scaler
forked from Gainer Basic Example: Analog Input with Scaler (diff: 2)
A very basic example on how to scale an analog input with a Scaler filter Reference http://funnel.cc/Software/ActionScript3
ActionScript3 source code
/**
* Copyright shihu ( http://wonderfl.net/user/shihu )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/wQpH
*/
// forked from kotobuki's Gainer Basic Example: Analog Input with Scaler
// forked from kotobuki's Gainer Basic Example: Analog Input
// forked from kotobuki's Gainer Basic Example: SignalScope
// A very basic example on how to scale an analog input
// with a Scaler filter
//
// Reference
// http://funnel.cc/Software/ActionScript3
package {
import flash.display.Sprite;
import flash.events.Event;
import funnel.*;
import funnel.gui.*;
[SWF(backgroundColor="0x808080")]
public class GainerTest extends Sprite {
private var gio:Gainer;
private var scope:SignalScope;
public function GainerTest() {
gio = new Gainer();
scope = new SignalScope(0, 5, 200, "ain 0");
addChild(scope);
var gui:GainerGUI = new GainerGUI();
addChild(gui);
gio.gui = gui;
gui.setPosition(IOModuleGUI.LEFT_BOTTOM);
// Scale the range of the input from 0.1-0.6 to 0-1
// 0.1から0.6まで変化する入力を0から1までにスケーリングする
gio.analogInput(0).addFilter(new Scaler(0.4, 0.6, 0, 1, Scaler.LINEAR, true));
addEventListener(Event.ENTER_FRAME, loop);
}
private function loop(event:Event):void {
scope.update(gio.analogInput(0));
}
}
}
