Question

I have a problem when I add an ANE (that I built by myself) to a Flex mobile project.

The problem is that the size of the objects are different than before I add the ANE. I've never used this ANE, I've only added it.

Here is an image before I add the ANE:

enter image description here

And an image after I add the ANE:

enter image description here

As you can see, the size of whole app are different. Do you know which can be the problem?

Thanks in advance

** Update info **

Code on ios:

#import "FlashRuntimeExtensions.h"

FREContext eventContext;

FREObject init(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[])
{
    eventContext = ctx;

    NSLog(@"init");

    return NULL;
}


void CameraExtContextInitializer(void* extData, const uint8_t* ctxType, FREContext ctx, uint32_t* numFunctionsToTest, const FRENamedFunction** functionsToSet)
{
    NSLog(@"camera ext context initializer");
    *numFunctionsToTest = 1;

    FRENamedFunction* func = (FRENamedFunction*) malloc(sizeof(FRENamedFunction) * *numFunctionsToTest);

    func[0].name = (const uint8_t*) "init";
    func[0].functionData = NULL;
    func[0].function = &init;

    *functionsToSet = func;
}

void CameraExtensionUniversalInitializer(void** extDataToSet, FREContextInitializer* ctxInitializerToSet, FREContextFinalizer* ctxFinalizerToSet)
{
    NSLog(@"Camera extension initializer");
    *extDataToSet = NULL;
    *ctxInitializerToSet = &CameraExtContextInitializer;
}

Code of library in AS:

package com.xxx.Controller
{   
    import flash.events.EventDispatcher;
    import flash.events.IEventDispatcher;
    import flash.events.StatusEvent;
    import flash.external.ExtensionContext;

    public class ReaderDeviceExtensionController extends EventDispatcher
    {

        private static var _instance:ReaderDeviceExtensionController;
        private var extContext:ExtensionContext;

        public function ReaderDeviceExtensionController(enforcer:SingletonEnforcer)
        {
            super();
            extContext = ExtensionContext.createExtensionContext( "com.xxx.Controller", "" );

            if ( !extContext ) {
                throw new Error( "Reader device native extension is not supported on this platform." );
            }

        }

    public static function get instance():ReaderDeviceExtensionController {
        if ( !_instance ) {
            _instance = new ReaderDeviceExtensionController( new SingletonEnforcer() );
            _instance.init();
        }

        return _instance;
    }

    public function dispose():void { 
        extContext.dispose(); 
    }

    private function init():void {
        extContext.call( "init" );
    }
}
}

class SingletonEnforcer {

}

Extension.xml:

<extension xmlns="http://ns.adobe.com/air/extension/3.1"> 
    <id>com.xxx.Controller</id> 
    <versionNumber>0.0.1</versionNumber> 
    <platforms>
        <platform name="iPhone-ARM"> 
            <applicationDeployment> 
                <nativeLibrary>libTestSimpleAne.a</nativeLibrary>
                <initializer>CameraExtensionUniversalInitializer</initializer>
            </applicationDeployment>
        </platform>
    </platforms> 
</extension>

I build the ANE with the following ADT command:

adt -package -target ane MWCameraNativeExtension.ane extension.xml -swc NativeDevicePluginForCamera.swc -platform iPhone-ARM -C ios .

Code of my application in Flex:

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" title="HTMLMainContent">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Label x="346" y="290" fontSize="16" paddingLeft="20" text="HI HI HI"/>
</s:View>
Was it helpful?

Solution

Is this running on an iPad 3? My guess is that you are accidentally unlocking the retina resolution when you use the native extension.

The default iOS SDK that Flash Builder / packager uses is an older version that didn't support the retina resolution of the iPad 3. So when you package an application without a native extension you get the iPad 2 resolution and iOS scales everything. When you use a native extension and you specify a newer iOS SDK it will automatically use the native resolution of the device.

Try tracing out stage.stageWidth and stage.stageHeight with and without the extension included. Also, check in the Project Properties -> Flex Build Packaging -> Apple iOS -> Native Extensions -> Apple iOS SDK box. If that is populated then you are most likely have the problem I described.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top