import gainer.*;
var ioModule:Gainer = new Gainer("localhost", 2000, Gainer.MODE1, true);
var threshold:Number = 120;
ioModule.onReady = function() {
this.beginAnalogInput();
//set "loop" as the event handler for onEnterFrame (scope is "ioModule")
//onEnterFrameのイベントハンドラにloopをセット(スコープはioModule)
_root.onEnterFrame = mx.utils.Delegate.create(this, loop);
//synchronized communication with the I/O module
//I/Oモジュールと同期した通信
this.onFinished = function() {
if (this.analogInput[0] < threshold) {
this.turnOnLED();
} else {
this.turnOffLED();
}
}
}
//the scode of the following function is "ioModule"
//以下はioModuleのスコープで実行される
function loop():Void {
trace(this.analogInput[0]);
}