views:

24

answers:

1

I have a bunch of classes in an SWF file. I'd like to use them in my Flash project. How do I import them?

External SWF

package com.external
{
    public class Class1 {}
}

In my project I want to write

import com.external.*;

var myclass:Class1 = new Class1();
A: 
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoad);
loader.load(new URLRequest("external.swf"));
function onLoad(e:Event):void
{
  var loaderInfo:LoaderInfo = LoaderInfo(e.target);
  var loadedSWF:DisplayObject = loaderInfo.content;
  var ClassType:Class = loaderInfo.applicationDomain.getDefinition("com.external.Class1") as Class;
  var t:Object = new ClassType();
}
Amarghosh