Adobe AIR:错误 #3500

Adobe AIR: Error #3500

编辑:我终于能够制作一个 "Hello, World!" 项目集。如果您也遇到 Error #3500 问题,请参阅 以获取工作项目集。

我目前正在使用 FlashDevelop 为 Adob​​e AIR 制作 "Hello, World!" 本机扩展。因此,我的本机扩展旨在供我正在编程的 Windows-x86 平台使用。

我通过(自定义)批处理文件构建了 ANE。使用 ANE 的测试 AIR 应用程序编译得很好,但是,就像我看到的很多其他人的帖子一样,我得到 Error #3500: The extension context does not have a method with the name helloWorld.

三天来我一直在努力了解发生了什么,尽管修复了几个原因,但我仍然遇到同样的错误。

似乎应用程序 运行time 从未真正调用 initializeExtension 函数,因为 DebugView 不跟踪任何东西,即使我的初始化程序使用 OutputDebugString(L"Extension initialized");.

发了一大堆代码感觉有点不好意思,三天看了几十个网页,就是不知道我的问题出在哪里。

无论如何,应用程序构建分 3 步完成:

1) 使用 Release 标记在 Visual Studio 中构建 DLL。我发布该代码作为对 Michael 下面评论的回应,但是,我不确定错误是从那里来的。

我的本机端主要由头文件和C++文件组成:

// -------------------------
// | NativeExtensionTest.h |
// -------------------------

#pragma once

#include "FlashRuntimeExtensions.h"

#ifdef __cplusplus
EXTERN_C
{
#endif

    __declspec(dllexport) void initializeExtension(
    void** dataToSet,
    FREContextInitializer* contextInitializer,
    FREContextFinalizer* contextFinalizer
    );


    __declspec(dllexport) void finalizeExtension(
        void* extData
        );


    __declspec(dllexport) void initializeContext(
        void* contextData,
        const uint8_t* contextType,
        FREContext context,
        uint32_t* nFunctionsToSet,
        const FRENamedFunction** functionsToSet
        );


    __declspec(dllexport) void finalizeContext(
        FREContext context
        );


    __declspec(dllexport) FREObject helloWorld(
        FREContext context,
        void* functionData,
        uint32_t argc,
        FREObject argv[]
        );

#ifdef __cplusplus
}
#endif

下面是函数的实现:

// ------------------
// | HelloWorld.cpp |
// ------------------

#pragma once

#include "stdafx.h" // precompiled header ; includes cstdlib, cstring and windows.h
#include "FlashRuntimeExtensions.h"
#include "NativeExtensionTest.h"


using namespace std;


void initializeExtension(
void** dataToSet,
FREContextInitializer* contextInitializer,
FREContextFinalizer* contextFinalizer
)
{
    dataToSet = NULL;
    *contextInitializer = &initializeContext;
    *contextFinalizer = &finalizeExtension;
}



void finalizeExtension(
    void* extData
    )
{ }



void initializeContext(
    void* contextData,
    const uint8_t* contextType,
    FREContext context,
    uint32_t* nFunctionsToSet,
    const FRENamedFunction** functionsToSet
    )
{
    *nFunctionsToSet = 1;
    FRENamedFunction* functions = (FRENamedFunction*)malloc(sizeof(FRENamedFunction)* (*nFunctionsToSet));

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

    *functionsToSet = functions;
}


void finalizeContext(
    FREContext context
    )
{ }


FREObject helloWorld(
    FREContext context,
    void* functionData,
    uint32_t argc,
    FREObject argv[]
    )
{
    char* hello = "Hello, World!";
    unsigned int helloLength = strlen(hello) + 1;
    FREObject ret;

    FRENewObjectFromUTF8(helloLength, (const uint8_t*)hello, &ret);

    return ret;
}

根据 alebianco 的要求,here is the build log 在构建 DLL 时。请注意,在自定义构建批处理文件执行结束时,我在日志的最后有一个错误。我不知道这个错误是从哪里来的;我上次构建该项目时没有出现该错误。此外,它可能是 FlashDevelop 内部的。

2) 构建 ANE。我正在使用批处理文件 运行 以下命令:

为了构建 SWC,我调用了 compc。变量展开后是这样的:

compc -include-sources"C:\Users\Anthony Dentinger\Desktop\Native Extension Test\src" -output "C:\Users\Anthony Dentinger\Desktop\Native Extension Test\ANE Build Files\NativeExtHelloWorld.swc" -load-config "C:\Users\Anthony Dentinger\AppData\Local\FlashDevelop\Apps\flexsdk.6.0\frameworks\air-config.xml" -swf-version 14

我的 src 文件夹包含一个简单的 class:

package
{
    import flash.events.EventDispatcher;
    import flash.external.ExtensionContext;


    public class NativeExtHelloWorld extends EventDispatcher {

        private var extContext:ExtensionContext;

        public function NativeExtHelloWorld()
        {
            extContext = ExtensionContext.createExtensionContext("NativeExtHelloWorld", "helloWorldContext");
        }

        public function helloWorld() : String
        {
            return String(extContext.call("helloWorld"));
        }

    }

}

反过来,在将我的 Visual Studio 文件夹中的 DLL 和 library.swf(我从 SWC 中提取的)复制到 ANE Build Files\platforms\Windows-x86 之后,我使用 [=72] 构建了 ANE =]adt。变量扩展后,命令如下所示:

call adt -package -target ane "C:\Users\Anthony Dentinger\Desktop\Native Extension Test\ANE Build Files\HelloExtension.ane" "C:\Users\Anthony Dentinger\Desktop\Native Extension Test\ANE Build Files\descriptor.xml" -swc "C:\Users\Anthony Dentinger\Desktop\Native Extension Test\ANE Build Files\NativeExtHelloWorld.swc" -platform "Windows-x86" -C "C:\Users\Anthony Dentinger\Desktop\Native Extension Test\ANE Build Files\platforms\Windows-x86" .

这是我提供的扩展描述符adt:

<?xml version="1.0" encoding="utf-8"?> 
<extension xmlns="http://ns.adobe.com/air/extension/3.1">

    <id>NativeExtHelloWorld</id> <!--I'll later change that ID to something like com.example.myExt.HelloWorld-->
    <name>Exension Name</name>
    <description>Description of the Extension</description>
    <versionNumber>0.0.1</versionNumber>
    <copyright>© 2010, Examples, Inc. All rights reserved.</copyright>

    <platforms>
        <platform name="Windows-x86">
            <applicationDeployment>
                <nativeLibrary>HelloWorld.dll</nativeLibrary>
                <initializer>initializeExtension</initializer>
                <finalizer>finalizeExtension</finalizer>
            </applicationDeployment>
        </platform>
    </platforms>

</extension>

3) 构建实际的应用程序。我正在使用 FlashDevelop 创建的默认批处理文件(经过两次修改以包含 ANE)来构建 AIR AS3 投影仪。

请注意,如果我收到错误 #3500,这意味着(我想)我的应用程序已成功包含来自 ANE 的 class,因为构造函数正在运行。

这是我正在使用的应用程序描述符,希望对您有所帮助。

<?xml version="1.0" encoding="utf-8" ?> 
<application xmlns="http://ns.adobe.com/air/application/15.0">

    <id>TEST</id>
    <versionNumber>1.0</versionNumber>
    <filename>TEST</filename>
    <name>TEST</name>

    <initialWindow> 
        <title>TEST</title> 
        <content>TEST.swf</content> 
        <systemChrome>standard</systemChrome> 
        <transparent>false</transparent> 
        <visible>true</visible> 
        <minimizable>true</minimizable> 
        <maximizable>true</maximizable> 
        <resizable>true</resizable> 
    </initialWindow> 

    <supportedProfiles>extendedDesktop</supportedProfiles>

    <extensions>
        <extensionID>NativeExtHelloWorld</extensionID>
    </extensions>
</application>

我正在使用与 AIR SDK (22.0.0) 合并的 Flex (4.6.0)。

我是不是做错了什么?什么可以帮助我解决这个问题?

再次抱歉,我发布了很多代码;我已尝试精简到最相关的部分。

提前致谢!

我已经以某种方式解决了问题,现在一切正常。我试着回去看看我做错了什么,但我不太明白。我的猜测是复制和解压缩 ANE 的批处理文件之一使用了错误的目标,所以我最终使用了相同的旧 ANE,而不是使用我正在构建的 ANE(愚蠢的我)。

应 Colonize.bat 的请求,here is a working Hello, World! example。我使用 VisualStudio 2013 和 FlashDevelop 制作了这个。

您可以在以下文件中找到几个 Error #3500 原因:

  • 1_Build_DLL/Hello World/main.cpp
  • 2_Build_ANE/lib/descriptor.xml
  • 2_Build_ANE/src/HelloWorldExtension.as

我读到(或遇到过!)的一些其他错误的原因,在其他文件中也有说明。事实上,自定义批处理文件指明了制作和使用您自己的 ANE 所要遵循的程序。

注意 :不要尝试直接从这些文件构建。我使用批处理文件是为了不必手动 运行 命令和 copy/paste/unzip 文件,因此目标和环境变量在您的计算机上将无效。