I'm doing a simple bit of code. I have a class Plugin that is meant to be extended, with a function 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;
}
}
}
And my main class which loads the plugins, and then initialises them:
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]);
}
}
}
But at the end, when I try to use the initialise function, it gives me this error:
TypeError: Error #1034: Type Coercion failed: cannot convert me.bleachisback.cocmod::CoCMain@4dfc041 to me.bleachisback.cocmod.CoCMain.
at me.bleachisback.cocmod::CoCMain/pluginLoadingComplete()
Implying I cannot convert a class to itself???
var plugin:e.target.content.mainClass() = new e.target.content.mainClass();or setting a class variable...var newClass:Class = e.target.content.mainClass();and thenvar plugin:newClass = new newClass();- Jonny Henly1046: Type was not found or was not a compile-time constant: newClass. I have also triedvar plugin:Plugin = new e.target.content.mainClass();but then it just gives me this error:Error #1034: Type Coercion failed: cannot convert plugin.bleachisback.testPlugin::TestMain@afc6309 to me.bleachisback.cocmod.Plugineven though TestMain does extend Plugin. - user2885503_mainand then setting it equal tomain, i.e._main = new CoCMain();and then_main = main. The error is saying that your trying to convert the objectCoCMain@4dfc041, which is aCoCMain Objectat memory location4dfc041, to aClass. - Jonny HenlyCoCMainto another SWF? - You may try to exclude this class from this SWF (not so easy when Flash and fla is used). - Lukasz 'Severiaan' Grela