3

I'm creating native extension with Flex 3.6. Coded native side then created Flex Library Project and then create .ane file. Finally imported .ane file to myFlex Project.
Here is the problem I had. While I'm debugging app, "1046: Type was not found or was not a compile-time constant: ExtensionContext" error occurs. Attached the Library project .as class .

Thanks in Advance

package com.extension.samples
{
    import flash.events.EventDispatcher;
    import flash.events.IEventDispatcher;
    import flash.external.ExtensionContext;

    public class NetworkConnectionANE extends EventDispatcher
    {
        public var _extContext : ExtensionContext;

        public function NetworkConnectionANE(target:IEventDispatcher=null)
        {
            _extContext = ExtensionContext.createExtensionContext("com.extension.samples.NetworkConnectionANE", null);
            super(target);
        }
        public function Connect(path:String):int
        {
            return _extContext.call("nativeFunc", path);
        }
        public function dispose():void
        {
            _extContext.dispose();
        }
    }
}

Edit: I tried to use .swc file that created from library project in another Flex Desktop app, but the same error
Also tried with _extContext = ExtensionContext.createExtensionContext("com.extension.samples.NetworkConnectionANE","");
Edit: The problem about Flex SDK,no problem in SDK 4.6. Now the question is, How to use Extension in lib project in Flex 3.6 SDK ?

3 Answers 3

6

Right click on the project in flash builder goto properties of project and add air libraries in the flex library compiler.

1
  • +1 That is the correct way to solve the compile-time error for flash.external.ExtensionContext being not found Jun 18, 2013 at 17:09
1

I had the same problem but it was resolved in the following way:

  1. File > New > Flex Library Project
  2. Check the "Include Adobe AIR Libraries" option
-1

As I know ExtensionContext.createExtensionContext() can be null in these cases:

  1. The call is not in an .ane file. You cannot call this from a .swc or a .swf file. In other words it needs to be compiled to an .ane file before calling it.

  2. You try to use the extension in a platform, that is not supported by the extension. For example you try to use an iOS extension on PC.

  3. The ID for the extension does not exists. The extension ID must be the same, as the one you specify in the extension.xml like:

    <extension xmlns="http://ns.adobe.com/air/extension/3.5">
        <id>com.extension.samples.NetworkConnectionANE</id>
        <versionNumber>0.0.1</versionNumber>
        ....
    

btw you dont need to set the second parameter of the ExtensionContext.createExtensionContext call, unless you want to specify OS-specific APIs (I havent even seen apps, that do this)

3
  • Thanks, but finally I found that extension is working on Flex v4.6 SDK. So the problem in Flex SDK that I use v3.6. I already couldn't see ExtensionContext class in flash.external package in SDK v3.6.0. This is the problem.Now I'm trying to learn if Flex v3.6 supports Native Extension. If yes, how to create library project in v3.6 for Native Ext.
    – nadir.shpz
    Dec 5, 2012 at 7:45
  • @nthere9 Its because it uses an older version of AIR. ExtensionContext.createExtensionContext requies AIR 2.5. You can see what you use in the extension's xml file in the xmnlns tag (my example uses 3.5). Why do you need to use Flex 3.6? ANE-s should not contain any Flex code...
    – sydd
    Dec 5, 2012 at 13:20
  • you are so right, When I create with 3.6,I see message "Flex 3.6 requires Air v1.5" but Native Extension is supported after Air v3.0 for desktop(help.adobe.com/en_US/air/build/…), Thanks
    – nadir.shpz
    Dec 5, 2012 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.