Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make my device vibrate?

I'm making a game in Flash for Android with AS3. I want the user to know that he pressed a button by making the device vibrate for a brief second. Can someone explain to me how I can make this happen? Do I need to import a specific class and what should the code look like?

Thanks in advance!

like image 722
David W Avatar asked Apr 20 '12 07:04

David W


1 Answers

To use the Vibration extension, an AIR application does the following:

Checks if the extension is supported by calling isSupported. Causes the device to vibrate by calling vibrate(), specifying the duration of the vibration in milliseconds as a parameter.

var vibe:Vibration;
if (Vibration.isSupported)
{
    vibe = new Vibration();
    vibe.vibrate(2000);
}

Android applications For an Android application, include the Vibration permission in your application descriptor file:

Android Permission : <uses-permission android:name="android.permission.VIBRATE"/>

Reference : http://www.adobe.com/devnet/air/native-extensions-for-air/extensions/vibration.html

like image 51
Vinayak Bevinakatti Avatar answered Nov 13 '22 15:11

Vinayak Bevinakatti