Copy link to clipboard
Copied
Hi
I have a blocking issue for native extensions when targetting the MacOS-x86 platform. (in my case Snow Leopard)
I succeded in packaging the ANE file, but I have this error when using it in my test app:
[SWF] tekhnia.simpleAirNativeExtension - 2 871 octets après la décompression
[SWF] simpleAirNativeExtensionTest.swf - 2 119 250 octets après la décompression
Context: [object ExtensionContext] in /Users/vandrito/Documents/Projets/o3sui/.metadata/.plugins/com.adobe.flexbuilder.project.ui/ANEFiles/simpleAirNativeExtensionTest/macosx/simpleAirNativeExtension.ane
ArgumentError: Error #3500: The extension context does not have a method with the name isSupported.
at flash.external::ExtensionContext/_call()
at flash.external::ExtensionContext/call()
at tekhnia.org.simpleAirNativeExtension::simpleAirNativeExtension/isSupported()[/Users/vandrito/Documents/Projets/o3sui/simpleAirNativeExtension/src/tekhnia/org/simpleAirNativeExtension/simpleAirNativeExtension.as:16]
at simpleAirNativeExtensionTest/init()[/Users/vandrito/Documents/Projets/o3sui/simpleAirNativeExtensionTest/src/simpleAirNativeExtensionTest.mxml:15]
at simpleAirNativeExtensionTest/___simpleAirNativeExtensionTest_WindowedApplication1_creationComplete()[/Users/vandrito/Documents/Projets/o3sui/simpleAirNativeExtensionTest/src/simpleAirNativeExtensionTest.mxml:5]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()
at mx.core::UIComponent/set initialized()
at mx.managers::LayoutManager/doPhasedInstantiation()
at mx.managers::LayoutManager/doPhasedInstantiationCallback()
In fact it seems that the initializer is not executed. This is my extension declaration file:
<extension xmlns="http://ns.adobe.com/air/extension/3.1">
<id>tekhnia.simpleAirNativeExtension</id>
<versionNumber>1.0.0</versionNumber>
<name>tekhnia.simpleAirNativeExtension</name>
<copyright>@2011 OpenTekhnia, Techniware</copyright>
<platforms>
<platform name="MacOS-x86">
<applicationDeployment>
<nativeLibrary>simpleAirNativeExtension.framework</nativeLibrary>
<initializer>initNativeExtension</initializer>
<finalizer>doneNativeExtension</finalizer>
</applicationDeployment>
</platform>
</platforms>
</extension>
That's my *.m file in the xcode framework project:
#import "simpleAirNativeExtension.h"
FREObject isSupported(FREContext ctx,
void *functionData,
uint32_t argc,
FREObject argv[]) {
FREObject retObj;
FRENewObjectFromBool(1, &retObj);
return retObj;
}
// contextInitializer()
//
// The context initializer is called when the runtime creates the extension context instance.
void contextInitializer(void* extData, const uint8_t* ctxType, FREContext ctx,
uint32_t* numFunctions, const FRENamedFunction** functionsToSet) {
*numFunctions = 1;
FRENamedFunction* func = (FRENamedFunction*)malloc(sizeof(FRENamedFunction) * (*numFunctions));
func[0].name = (const uint8_t*) "isSupported";
func[0].functionData = NULL;
func[0].function = &isSupported;
*functionsToSet = func;
}
// contextFinalizer()
//
// The context finalizer is called when the extension's ActionScript code
// calls the ExtensionContext instance's dispose() method.
// If the AIR runtime garbage collector disposes of the ExtensionContext instance, the runtime also calls
// contextFinalizer().
void contextFinalizer(FREContext ctx) {
// Nothing to clean up.
return;
}
// initMulticastSocket()
//
// The extension initializer is called the first time the ActionScript side of the extension
// calls ExtensionContext.createExtensionContext() for any context.
void initNativeExtension(void** extDataToSet, FREContextInitializer* ctxInitializerToSet,
FREContextFinalizer* ctxFinalizerToSet) {
*ctxInitializerToSet = &contextInitializer;
*ctxFinalizerToSet = &contextFinalizer;
}
// done()
//
// The extension finalizer is called when the runtime unloads the extension. However, it is not always called.
void doneNativeExtension(void* extData) {
// Nothing to clean up.
return;
}
and that's my .h:
//
// simpleAirNativeExtension.h
// simpleAirNativeExtension
//
// Created by Victor Andritoiu on 17/10/11.
// Copyright (c) 2011 OpenTekhnia. All rights reserved.
//
#import <Foundation/Foundation.h>
#include "Adobe Air/FlashRuntimeExtensions.h"
void initNativeExtension(void** extDataToSet, FREContextInitializer* ctxInitializerToSet,
FREContextFinalizer* ctxFinalizerToSet);
void doneNativeExtension(void* extData);
FREObject isSupported(FREContext ctx,
void *functionData,
uint32_t argc,
FREObject argv[]);
void contextInitializer(void* extData, const uint8_t* ctxType, FREContext ctx,
uint32_t* numFunctions, const FRENamedFunction** functionsToSet);
void contextFinalizer(FREContext ctx);
@Interface simpleAirNativeExtension : NSObject
And finally my AS3 code for the lib:
package tekhnia.org.simpleAirNativeExtension
{
import flash.external.ExtensionContext;
public class simpleAirNativeExtension {
/** extension context */
protected var context: ExtensionContext;
public function simpleAirNativeExtension() {
context = ExtensionContext.createExtensionContext("tekhnia.simpleAirNativeExtension", "");
trace("Context: " + context + " in " + ExtensionContext.getExtensionDirectory("tekhnia.simpleAirNativeExtension").nativePath);
}
public function isSupported(): Boolean {
return context.call("isSupported") as Boolean;
}
}
}
and for the app using it:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="init()">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import tekhnia.org.simpleAirNativeExtension.simpleAirNativeExtension;
protected function init(): void {
var sane: simpleAirNativeExtension = new simpleAirNativeExtension();
trace(sane.isSupported());
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Placer ici les éléments non visuels (services et objets de valeur, par exemple). -->
</fx:Declarations>
</s:WindowedApplication>
If anybody succeeded in using extensions on MacOS, please first tell me that s possible then, maybe help me on getting the error that I make.
Thanks a lot
Victor
Workaround found:
Need to launch adl as a line command (depends on your directory config, of course):
/Applications/Adobe\ Flash\ Builder\ 4.6/sdks/4.6.0/bin/adl -runtime /Library/Frameworks/ -extdir /Users/vandrito/Desktop/simpleAirNativeExtension/launch/extensions -profile extendedDesktop /Users/vandrito/Documents/Projets/o3sui/simpleAirNativeExtensionTest/bin-debug/simpleAirNativeExtensionTest-app.xml
Pay attention to the library location: it is the one of the Air 3.1 install. Did not check the
...Copy link to clipboard
Copied
UPDATE:
Packaging the application it works. In fact only launching it from the Flash Builder leads to this issue (either run or debug).
Anybody knows how to deal with this in order to be able to debug it anyway ?
Copy link to clipboard
Copied
Which SDK version do you have in your Flash Builder?
-Lisa
Copy link to clipboard
Copied
Flex SDK 4.6 (prerelease), Air 3.1
It works when packaging a native application for Mac OS X running it with the Air 3.1 prerelease.
Launching the app from the Flash Builder 4.6, doesn't work.
I know that is a prerelease and, if a real issue, this woill be corrected. It is just that I really need to debug the app, since I am developping a very complex extension for our simulation tools' GUI. So if there is a workaround, would be perfect.
Thanks
Victor
Copy link to clipboard
Copied
Workaround found:
Need to launch adl as a line command (depends on your directory config, of course):
/Applications/Adobe\ Flash\ Builder\ 4.6/sdks/4.6.0/bin/adl -runtime /Library/Frameworks/ -extdir /Users/vandrito/Desktop/simpleAirNativeExtension/launch/extensions -profile extendedDesktop /Users/vandrito/Documents/Projets/o3sui/simpleAirNativeExtensionTest/bin-debug/simpleAirNativeExtensionTest-app.xml
Pay attention to the library location: it is the one of the Air 3.1 install. Did not check the same trick with Flash Builder 4.6 Air install.
Then use a fake web debugger to connect to the process (if compiled in debug mode). See here how to do (french):
Victor