- 积分
- 136401
- 注册时间
- 2014-12-27
- 最后登录
- 2026-1-24
- 在线时间
- 605 小时
- 威望
- 562
- 贡献
- 29
- 金币
- 52903
- 钢镚
- 1422
- 交易凭证
- 1
- 分享
- 0
- 精华
- 33
- 帖子
- 2094
- 主题
- 1742
TA的每日心情 | 擦汗 2018-4-10 15:18 |
|---|
签到天数: 447 天 [LV.9]以坛为家II
超级版主
    
- 威望
- 562
- 贡献
- 29
- 金币
- 52903
- 钢镚
- 1422
 
|
应用下载
| 应用名称: |
Vibration |
| 支持64位: |
|
| 当前版本: |
未知 |
| 运行平台: |
Android IOS |
| 开发语言: |
ActionScript 3 |
| 应用类别: |
ANE-多平台 |
| 应用简介: |
Makes an iOS or Android device vibrate. |
Note: By clicking the download link for any source examples on this page, you acknowledge that you have read and agree to the Adobe AIR SDK License Agreement. These files are considered Sample Code. Note: Adobe recommends using the next version of Flash Builder for developing native extensions for Adobe AIR. Sign up now to get access to the prerelease of Flash Builder 4.6.
The Vibration class is a native extension for Adobe AIR. It allows AIR application developers, from ActionScript, to use the vibration feature of an Android or iOS mobile device. The attached ZIP file contains: - The ActionScript library in the directory VibrationActionScriptLibrary: This directory contains the Flash Builder project for creating the ActionScript side of the Vibration extension.
- The Android native library in the directory VibrationAndroidLibrary: This directory contains an Eclipse project for creating the Android native side of the Vibration extension. To build the Eclipse project, first copy FlashRuntimeExtension.jar from <AIR_SDK>/lib/android/FlashRuntimeExtensions.jar to the directory VibrationAndroidLibrary\libs.
- The iOS native library in the directory VibrationiOSLibrary: This directory contains an Xcode project for creating the iOS native side of the Vibration extension. To build the Xcode project, first copy FlashRuntimeExtension.h from <AIR_SDK>/include/FlashRuntimeExtensions.h to the directory
VibrationiOSLibrary. - A directory called ReadyToUseExtension: This directory contains everything the AIR application developer needs to use the native extension: the ANE file, the SWC file, and a text file that contains the extension ID.
- A directory called TestVibrationExtension: This directory contains a sample AIR application that uses the Vibration native extension.
The ActionScript library
The ActionScript library contains the Vibration class. The Vibration class provides the AIR application this public property and method: - public static function get isSupported(): Boolean
- public function vibrate(duration:Number): void
The AIR application can create many instances of the Vibration class. However, the Vibration class creates only one ExtensionContext class instance that all the Vibration instances share.
Application usage
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.
For example:
- <font face="inherit"><font style="font-size: 13.63636302947998px">var vibe:Vibration;
- if (Vibration.isSupported)
- {
- vibe = new Vibration();
- vibe.vibrate(2000);
- }</font></font>
复制代码 Android applicationsFor an Android application, include the Vibration permission in your application descriptor file:- Android Permission : <uses-permission android:name="android.permission.VIBRATE"/>
复制代码 iOS applicationsFor an iOS application:- The isSupported property always returns true. On iOS devices, no native API is available to determine whether the vibration feature is supported.
- The duration value passed to vibrate() is ignored. The device vibrates for a duration determined by iOS.
The Android native library
The Android native library is implemented in Java, using the native extension Java API. The native library includes the following classes:- VibrationExtension implements FREExtension
- VibrationExtensionContext extends FREContext
- VibrationSupportedFunction, VibrationInitNativeCode, and VibrationVibrateFunction each implement FREFunction
The native library also contains examples of using these FREObject methods:In its initialization, the native library uses the getActivity() method of the FREContext class to get the application's Android Activity. Using the returned Activity, the initialization method, which isVibrationInitNativeCodeFunction.call(), gets the vibration service:- Activity a = vibExtContext.getActivity();
- vibExtContext.androidVibrator = (Vibrator) a.getSystemService(Context.VIBRATOR_SERVICE);
复制代码 Note: The call from the ActionScript side to ExtensionContext.createExtensionContext() must return before the native library can call methods of the object derived from the FREContext class. Therefore, the callvibExtContext.getActivity() occurs in the initialization function that the ActionScript side calls after the return fromcreateExtensionContext(). The call to getActivity() cannot occur in the FREContext object constructor.
The iOS native library
The iOS native library is implemented in Objective C, using the native extension C API. The native library contains examples of these native extension C APIs:- The extension initializer and finalizer, using the signatures of FREInitializer() and FREFinalizer().
- The context initializer and finalizer, using the signatures of FREContextInitializer() andFREContextFinalizer().
- Native functions, using the signature of FREFunction(). The native functions are IsSupported(),InitNativeCode(), and VibrateDevice().
- FRENewObjectFromBool()
The function VibrateDevice() calls the iOS API AudioServicesPlaySystemSound() to vibrate the device. However, if the device does not support vibration, this iOS API call does nothing.Note: In the iOS native implementation, no initialization is necessary, and so the initialization native function,InitNativeCode(), does nothing. However, the function is necessary because the Android native implementation requires an initialization function. Therefore, to make the extension’s ActionScript interface the same for all native implementations, the iOS native implementation provides the stub.
Where to go from here
For more information about developing native extensions for Adobe AIR, see:For more information about using a native extension in an AIR application, see:
More Like This
相关链接:
Vibration native extension sample
http://www.riaxe.com/blog/200-adobe-air-anes/
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|