PDA

View Full Version : Cast external swf assets as custom class defenitions


Falibur
02-16-2009, 02:41 PM
Hello,

I am trying to cast external movieclips (inside swf with export names) as custom classes, so I can centralize my code.
Is that possible in the way I am trying like the following:

Loading external swf:
public function TestLoader()
{
login = new Login();
swfLib = "library.swf";
var mRequest:URLRequest = new URLRequest(swfLib);
var context:LoaderContext = new LoaderContext();
context.applicationDomain = ApplicationDomain.currentDomain;
mLoader.contentLoaderInfo.addEventListener(Event.C OMPLETE, addLogin);
mLoader.contentLoaderInfo.addEventListener(Progres sEvent.PROGRESS, onProgressHandler);
mLoader.load(mRequest, context);
}
when loaded:
public function addLogin(evt:Event):void {
var winLogin:Class = evt.target.applicationDomain.getDefinition("WinLogin") as Class;
var mcLogin:Login = new winLogin() as Login;
this.addChild(mcLogin);
}

this above code is not working as you can see, cause otherwise I wasn't here ;)

Basically what I am trying to do is extending the class (which is a movieclip class out of the external library) with one of my own classes 'Login'. 'Login' itself is a class which is extended by the MovieClip class so it should be handled like that.
Is this approach a good thought? If so, what's the correct way?
Or are there more options?

My environment:
Flash Develop/Flex3/Flash CS4 IDE(making the library)

Thanks in advance

suatsahin
03-17-2009, 01:49 PM
:confused:

i have same problem.. i cant solve that yet. Is there anybody that can solve this?