我正在做一些简单的代码。我有一个用于扩展的类插件,带有一个函数 initialise():
package me.bleachisback.cocmod {
import me.bleachisback.cocmod.CoCMain;
public class Plugin {
private var _main:CoCMain;
private var _name:String;
private var _desc:String;
private var _ver:String;
private var _auth:String;
internal var _enabled:Boolean = false;
internal function initialise(main:CoCMain, name:String, description:String, version:String, author:String):void {
_main = main;
_name = name;
_desc = description;
_ver = version;
_auth = author;
}
}
}
我的主类加载插件,然后初始化它们:
package me.bleachisback.cocmod {
import me.bleachisback.cocmod.Plugin;
public class CoCMain extends MovieClip {
private function pluginLoadingComplete(e:Event):void {
//This class extends Plugin
var plugin:Object = new e.target.content.mainClass();
var desc:XML = new XML(e.target.content.description);
trace(this); //outputs: [object CoCMain]
plugin.initialise(this, desc.name[0], desc.description[0], desc.version[0], desc.author[0]);
}
}
}
但最后,当我尝试使用初始化函数时,它给了我这个错误:
TypeError: Error #1034: Type Coercion failed: cannot convert me.bleachisback.cocmod::CoCMain@4dfc041 to me.bleachisback.cocmod.CoCMain.
at me.bleachisback.cocmod::CoCMain/pluginLoadingComplete()
暗示我不能将一个类转换为自身???