Reputation: 1184
I'm working on a project that features a Master swf that loads in child swfs as required. Is there a way to load in these child swfs in such a way that the constructor in their document class can be called with arguments?
as an example:
I have a child class that is loaded in at runtime that can be given an alignment argument in its constructor.
I load that in at runtime as a class, and instantiate it with arguments in the parent, Master swf.
Obviously I could create a secondary 'constructor' in the child that builds what I want after instantiation, I'd just like to know if there is a way to manage instantiation of loaded swfs, and/or load them into classes rather than display objects.
Upvotes: 1
Views: 111
Reputation: 810
A loaded SWF is already a constructed object. With AS3 you can get the classname and instantiate a new object:
pass in the object you want to 'duplicate' in the function below. It will get the classname and convert it into a class. Then, it wil create a new instance of that class, where you can pass in some arguments
public function getClassObj(obj:*, constructorArgument:*):* {
var objClass:Class = Class(getDefinitionByName(getQualifiedClassName(obj)));
var tempObj:* = new objClass(constructorArgument);
return tempObj;
}
Upvotes: 1