我正在嘗試進行AIR本機擴展,並且在成功編譯所有組件後,Flash Builder 4.6記錄「錯誤3500:擴展上下文不有名字的方法......「。AIR本機擴展「擴展上下文沒有帶名稱的方法」
下面是本機DLL的C++代碼:
#include "stdafx.h"
#include "TestANE.h"
#include "FlashRuntimeExtensions.h"
#include <string>
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
FREObject isSupported(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
FREObject result;
uint32_t isSupportedSwitch = 1;
FRENewObjectFromBool(isSupportedSwitch, &result);
return result;
}
FREObject getString(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
FREObject result;
const char *testString = "Hello World from C++!";
FRENewObjectFromUTF8(strlen(testString)+1, (const uint8_t *) testString, &result);
return result;
}
void taneContextInitializer(void* extData, const uint8_t* ctxType, FREContext ctx, uint32_t* numFunctions, const FRENamedFunction** functions) {
*numFunctions = 2;
FRENamedFunction* func = (FRENamedFunction*) malloc(sizeof(FRENamedFunction) * (*numFunctions));
func[0].name = (const uint8_t*) "isSupported";
func[0].functionData = NULL;
func[0].function = &isSupported;
func[1].name = (const uint8_t*) "getString";
func[1].functionData = NULL;
func[1].function = &getString;
*functions = func;
}
void taneContextFinalizer(FREContext ctx) {
return;
}
void taneInitializer(void** extData, FREContextInitializer* ctxInitializer, FREContextFinalizer* ctxFinalizer) {
*ctxInitializer = &taneContextInitializer;
*ctxFinalizer = &taneContextFinalizer;
}
void taneFinalizer(void* extData) {
return;
}
下面的代碼爲ActionScript 3的接口:
package com.tests.TestANE {
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
import flash.external.ExtensionContext;
public class TestANE extends EventDispatcher {
private var _ExtensionContext:ExtensionContext;
public function TestANE(target:IEventDispatcher=null) {
this._ExtensionContext = ExtensionContext.createExtensionContext("com.tests.TestANE", null);
super(target);
}
public function isSupported():Boolean {
return _ExtensionContext.call("isSupported") as Boolean;
}
public function getString():String {
return _ExtensionContext.call("getString") as String;
}
public function dispose():void {
this._ExtensionContext.dispose();
}
}
}
解決這個問題的任何幫助將不勝感激。
是整個錯誤信息? 「...」後面是什麼 –
這是一個總結。以下是完整的錯誤:'ArgumentError:Error#3500:擴展上下文沒有名稱爲getString的方法。 \t在flash.external :: ExtensionContext/_call() \t在flash.external :: ExtensionContext /()調用 \t在com.tests.TestANE :: TestANE /的getString()[M:\測試\ TestANE_SWC \ SRC \ TestANE \ TestANE.as:22] \t at TestANE/applicationInit()[M:\ Tests \ TestANE \ src \ TestANE.mxml:20] \t at TestANE/___ Test_WindowedApplication1_creationComplete()[M:\ Tests \ TestANE \ SRC \ TestANE.mxml:5]'... –
繼續:'在flash.events::EventDispatcher/dispatchEventFunction() \t在flash.events::EventDispatcher/dispatchEvent() \t在mx.core: :UIComponent/dispatchEvent()[E:\ dev的\ 4.Y \框架\項目\ FRAM ework \ src \ mx \ core \ UIComponent.as:13152] \t at mx.core :: UIComponent/set initialized()[E:\ dev \ 4.y \ frameworks \ projects \ framework \ src \ mx \ core \ UIComponent.as:1818] \t at mx.managers :: LayoutManager/doPhasedInstantiation()[E:\ dev \ 4.y \ frameworks \ projects \ framework \ src \ mx \ managers \ LayoutManager.as:842]' –