Vibration is a native extension that provides access to a device’s native vibration capabilities.
Some features:
- Provides access to native vibration functionality.
- Works across iOS and Android with the same code
- Sample project code and ASDocs reference
Sample
/** * __ __ __ * ____/ /_ ____/ /______ _ ___ / /_ * / __ / / ___/ __/ ___/ / __ `/ __/ * / /_/ / (__ ) / / / / / /_/ / / * \__,_/_/____/_/ /_/ /_/\__, /_/ * / / * \/ * http://distriqt.com * * This is a test application for the distriqt extension * * @author Michael Archbold & Shane Korin * */ package { import com.distriqt.extension.vibration.Vibration; import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event; import flash.events.MouseEvent; import flash.text.TextField; import flash.text.TextFormat; /** * Sample application for using the Vibration Native Extension * * @author Michael Archbold */ public class TestVibration extends Sprite { /** * Class constructor */ public function TestVibration() { super(); create(); init(); } // // VARIABLES // private var _text : TextField; // // INITIALISATION // private function create( ):void { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; var tf:TextFormat = new TextFormat(); tf.size = 24; _text = new TextField(); _text.defaultTextFormat = tf; addChild( _text ); stage.addEventListener( Event.RESIZE, stage_resizeHandler, false, 0, true ); stage.addEventListener( MouseEvent.CLICK, mouseClickHandler, false, 0, true ); addEventListener( Event.ACTIVATE, activateHandler, false, 0, true ); addEventListener( Event.DEACTIVATE, deactivateHandler, false, 0, true ); } private function init( ):void { try { Vibration.init( "your_dev_key" ); message( "Vibration Supported: "+ String(Vibration.isSupported) ); message( "Vibration Version: " + Vibration.service.version ); // // Add test inits here // } catch (e:Error) { trace(" >> " +e); } } // // FUNCTIONALITY // private function message( str:String ):void { trace( str ); _text.appendText(str+"\n"); } // // EVENT HANDLERS // private function stage_resizeHandler( event:Event ):void { _text.width = stage.stageWidth; _text.height = stage.stageHeight - 100; } private function mouseClickHandler( event:MouseEvent ):void { // // Do something when user clicks screen? // message("Sending vibrate command..."); Vibration.service.vibrate( 1000 ); } // // COMPASS NOTIFICATION HANDLERS // private function activateHandler( event:Event ):void { } private function deactivateHandler( event:Event ):void { trace( "deactivateHandler() "); } } }
RT @as3gamegears: New: Vibration (extension to access a device’s native vibration capabilities) http://t.co/Eqj5i9t0 #as3 #flash #gamedev