Hi all :-)
I am an android expert and I'd really love to create some cool extensions like the android notifications, but since I don't know much about Flex, I have a lot of trouble getting the test vibrator with native extension working.
(http://www.adobe.com/devnet/air/native-extensions-for-air/extensions/v ibration.html)
My sample is still buggy, it is probably beginner's bug, but I don't see how to fix it yet.
I am surely not the only native guy trying to do this, so I would like to sumarize here all the steps needed to have our first hello world Native Extension API
Here is my code for the sample view:
In HelloworldNativeExtension.mxml
Use the following code :
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import com.adobe.nativeExtensions.Vibration;
protected function testButton():void
{
textArea.text="Before vibration";
var vibe:Vibration;
if (Vibration.isSupported)
{
vibe = new Vibration();
vibe.vibrate(2000);
}
textArea.text="After vibration";
}
]]>
</fx:Script>
<s:Panel title="Exemple MXML" width="330">
<s:layout>
<s:VerticalLayout paddingLeft="15" paddingTop="15" paddingBottom="15" paddingRight="15"/>
</s:layout>
<s:Label x="223" y="173" text="test" id="textArea"/>
<s:Button label="Vibrate" click="testButton()"/>
<s:Label id="result" width="265"/>
</s:Panel>
</s:Application>
Well... so far my project doesn't compile because the library is loaded externally. It compiles fine if I add it as a bundled library, but then the virbrator can't work (External native code have to be loaded externally)
And thus so far I get the errors :
| Description | Ressource | Chemin | Emplacement | Type |
| 1046: Ce type est introuvable ou n'est pas une constante de compilation : [flash.display]::IBitmapDrawable. | HelloworldNativeExtension | Inconnu | Erreur Flex | |
| 1046: Ce type est introuvable ou n'est pas une constante de compilation : [flash.events]::IEventDispatcher. | HelloworldNativeExtension | Inconnu | Erreur Flex | |
| 1046: Ce type est introuvable ou n'est pas une constante de compilation : [flash.events]::IEventDispatcher. | HelloworldNativeExtension | Inconnu | Erreur Flex | |
| 1046: Ce type est introuvable ou n'est pas une constante de compilation : [flash.events]::IEventDispatcher. | HelloworldNativeExtension | Inconnu | Erreur Flex | |
| 1046: Ce type est introuvable ou n'est pas une constante de compilation : [flash.events]::IEventDispatcher. | HelloworldNativeExtension | Inconnu | Erreur Flex | |
| 1046: Ce type est introuvable ou n'est pas une constante de compilation : [flash.events]::IEventDispatcher. | HelloworldNativeExtension | Inconnu | Erreur Flex | |
| 1046: Ce type est introuvable ou n'est pas une constante de compilation : [flash.events]::IEventDispatcher. | HelloworldNativeExtension | Inconnu | Erreur Flex | |
| 1046: Ce type est introuvable ou n'est pas une constante de compilation : [flash.events]::IEventDispatcher. | HelloworldNativeExtension | Inconnu | Erreur Flex | |
| 1046: Ce type est introuvable ou n'est pas une constante de compilation : [flash.events]::IEventDispatcher. | HelloworldNativeExtension | Inconnu | Erreur Flex |
(Which means something like : 1046: this type cannot be resolved or is not in the buildpath ... So it probably means the project doesn't compile well)
So I'm still trying to figure out what to do, but I am close I think... Very close.
Yes, in fact you are very close ![]()
You will have to put an <extensions> tag in app-xml if not already done so:
<extensions>
<extensionID>com.adobe.Vibration</extensionID>
<extensions>
Then since it is FlashBuilder 4.5.1, you will have to package the android application through command line since it requires 1 more parameter -extdir :
adt -package -target apk . . . app.apk app.xml app.swf -extdir extensions
extensions is the directory which contains your .ane file. Checkout http://www.adobe.com/devnet/air/articles/extending-air.html#articlecon tentAdobe_numberedheader_1 for more details.
Thats all. You should be able to run your app now. Let me know if it still doesnt work.
Thanks,
Meet
AIR Team
Hi :-)
Thanks so much for you reply, I have moved even further this time! ![]()
But still one step to go!
I have followed what you said, but I am stuck at compiling the .swf out of my mxml application.
I use the command line program mxmlc, but it doesn't want to compile since the library is not recognised.
Well, with a bit of faith, I tried something like :
mxmlc "...\HelloworldNativeExtension.mxml" -extdir "...\ReadyToUseExtension\com.adobe.extensions.Vibration"
or
amxmlc –library-path+="...\ReadyToUseExtension\VibrationActionScriptLibrary. swc" -- "...\HelloworldNativeExtension.mxml"
But well, it didn't worked...
Is there a parameter to set so it recognise the library? or is there a way to override the check of the library while compiling the SWF ?
of course I looked at the online documentation on mxmlc
North America
Europe, Middle East and Africa
Asia Pacific