Detect the movement kotobuki forked:2favorite:0lines:33license : MIT License modified : 2009-12-07 12:41:44 Embed Tweet package { import flash.display.Sprite; import flash.events.Event; import funnel.*; [SWF(backgroundColor="0x808080")] public class DetectTheMovement extends Sprite { private var gainer:Gainer; private var scopeForInputSignal:SignalScope; private var scopeForDiff:SignalScope; private var scopeForSetPoint:SignalScope; private var sensorPin:Pin; private var setPoint:SetPoint; public function DetectTheMovement() { gainer = new Gainer(); sensorPin = gainer.analogInput(2); sensorPin.addFilter(new Convolution(Convolution.MOVING_AVERAGE)); scopeForInputSignal = new SignalScope(10, 10, 200, "Z axis"); addChild(scopeForInputSignal); scopeForDiff = new SignalScope(10, 70, 200, "raw - smoothed", -1, 1); addChild(scopeForDiff); scopeForSetPoint = new SignalScope(10, 130, 200, "divided by SetPoint", 0, 1); addChild(scopeForSetPoint); setPoint = new SetPoint([0.3, 0.05]); addEventListener(Event.ENTER_FRAME, onEnterFrame); } private function onEnterFrame(e:Event):void { scopeForInputSignal.update(sensorPin); var diff:Number = sensorPin.preFilterValue - sensorPin.value; scopeForDiff.update(diff); scopeForSetPoint.update(setPoint.processSample(diff)); } } } Code Fullscreen Preview Fullscreen gainer physical addChild addEventListener Event.ENTER_FRAME Event Sprite Number sort new page view favorite forked pv200 forked from: Detect the moveme.. fuwatty forked:0 favorite:0lines:33 (diff:2) pv145 forked from: Detect the moveme.. mesulions forked:0 favorite:0lines:33 (diff:1)