flash on 2010-2-9
前回の値
閾値
♥0 |
Line 18 |
Modified 2010-02-09 22:35:15 |
MIT License
archived:2017-03-20 19:27:26
ActionScript3 source code
/**
* Copyright mesulions ( http://wonderfl.net/user/mesulions )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/7Gb8
*/
package {
import flash.display.Sprite;
import gainer.*;
var lastValue:Number = 0; //前回の値
var threshold:Number = 10; //閾値
public class GainerTest extends Sprite {
gio.onReady = function():Void {
gio.beginAnalogInput();
_root.onEnterFrame = function():Void {
var currentValue:Number = gio.analogInput[0];
//前回の値と今回の値の差を閾値と比較する
if(Math.abs(currentValue - lastValue) > threshold) {
//急速な動きを検出した時にこの部分が実行される
trace( "changed:" + kastValue + " => " + currentValue);
}
lastValue = currentValue;
}
}
}
}