Skip to main content
Known Participant
October 22, 2013
Question

ReferenceError: Error #1065: Variable TestMain is not defined

  • October 22, 2013
  • 1 reply
  • 854 views

I'm loading a .swf and trying to find a class based on an embedded xml document in it. I've looked this problem up endlessly and everyone has either said "Your class isn't public", "Your classname is interfering with your document class", or "You aren't using the same ApplicationDomain", none of which are true. Here's my code:

In CoCMain.as, with a CoCMod.fla:

    private function pluginLoadingComplete(e:Event😞void {
       
var testXML:XML = new XML(new e.target.content.description);
        trace
(e.target.applicationDomain.hasDefinition("blah.blaah.testPlugin.TestMain"));//returns false
        trace
(ApplicationDomain.currentDomain.hasDefinition("blah.blaah.testPlugin.TestMain"));//returns false
        trace
(testXML.main[0]);//returns blah.blaah.testPlugin.TestMain
       
var pluginClass:Class = e.target.applicationDomain.getDefinition(testXML.main[0]) as Class;//error here
   
}

And in TestMain.as, with a TestMod.fla (this is the swf I am loading):

package blah.blaah.testPlugin {

   
public class TestMain {
       
public function TestMain():void {
           
super();
       
}      

       
public function onEnable():void {
            trace
("blah");
       
}
   
}  
}

And in frame 1 of TestMod.fla:

import blah.blaah.testPlugin.TestMain;

[Embed(source = 'main.xml', mimeType = "application/octet-stream")]
const description:Class;

The xml file:

<mod>

          <name>Test Mod</name>

          <description>Please ignore</description>

          <author>Bleachisback</author>

          <version>1.0</version>

          <main>blah.blaah.testPlugin.TestMain</main>

</mod>

The error I am getting:

ReferenceError: Error #1065: Variable TestMain is not defined.
    at flash
.system::ApplicationDomain/getDefinition()
    at me
.bleachisback.cocMod::CoCMain/pluginLoadingComplete()

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
October 22, 2013

copy and paste code where you add the listener that calls pluginLoadingComplete and the load method code.

also, make sure your loaded swf is using TestMain in blah/blaah/testPlugin by using a trace statement in TestMain.