0

I'm loading an external SWF as you normally would and I am handling the COMPLETE listener with:

var documentClass:Object;
function onComplete(loadEvent:Event)
{
    documentClass = Object(loadEvent.currentTarget.content);
}

This works perfectly and I can access variables and functions from the document class of the external SWF. However not all the other classes in the SWF's library aren't instantiated in the document class. I would also like to access variables and functions in these other classes, and I am currently using, for example:

var documentClass:Object;
var classOne:Class;
function onComplete(loadEvent:Event)
{
    documentClass = Object(loadEvent.currentTarget.content);
    classOne = loadEvent.target.applicationDomain.getDefinition("ClassName") as Class;
}

This also works. However, there are multiple other classes in the library which I want to access and it is extremely tedious to go through each of them using this method. I was hoping I could use getQualifiedDefinitionNames() (I'm using Flash CC and player 11.3 so it is available) but when I trace it, it doesn't seem to be working.

There has to be an easier way to access the other classes which I don't know of. Can anyone help?

Thank you, James

James Gain
  • 5
  • 1
  • 4
  • You should be able to use `getQualifiedDefinitionNames()`, unless you hit a security error. Check if so. – Vesper Jul 24 '14 at 13:16
  • @Vesper Hmm.. very strangely worked! I used trace(loadEvent.target.applicationDomain.getQualifiedDefinitionNames()); like I did before, and it traced. Before it didn't trace at all. How can I proceed to use this to access the classes now? – James Gain Jul 24 '14 at 13:24
  • If so, you can call `getDefinitionByName()` versus each of the strings returned, cast it to `Class` and then call `new ThatClass()` as normal, provided that class has 0 required arguments in the constructor, so you won't hit an argument mismatch error. – Vesper Jul 24 '14 at 13:52
  • @Vesper is there an easier way around this? I have been told by a friend that I should use the instance of the document class instead but I don't know exactly what he means - do you know? – James Gain Jul 25 '14 at 11:13
  • Instancing a document class will net you a completely working nested SWF, but there is one instanced already, so you get that like you do with `documentClass` line (it'll not be a class but an object instead), and then you cast it to `MovieClip` (provided it is one, normally it's true) and query its properties like normal. – Vesper Jul 25 '14 at 11:24
  • @Vesper Hmm... I see. Could you give me an example of how I would access another class from the document class like this then? Sorry if this is too much to ask but this is all very new to me. I've been experimenting for hours and I'm just getting 'unidentified' errors. – James Gain Jul 25 '14 at 11:44

0 Answers0