Loading External MovieClip Assets and Custom Class Problem

Hair pulling time. For some reason I am having a major trauma over this one so I am putting it out there on my blog for some potential guidance please.

Scenario:

  • In a UILibrary.fla I have a MovieClip named CustomMC with a linkage id of CustomClass
     +    I have a class named CustomClass.as with all the CustomMC assets declared
    
  • I then import the UILibrary.swf into a seperate app and load the CustomMC
  • var myClass:Class = loader.contentLoaderInfo.applicationDomain.getDefinition(name) as Class;
  • var obj:Object = new myClass();
  • I can now add this to the DisplayList no problem
  • Problem is registering the loaded asset to the CustomClass.as

No matter what I do whether registerClassAlias and the getClassByAlias I end up with a whole heap of problems such as cannot convert CustomClass to Class (my casting fails), the DisplayObject ends up as null, the CustomClass is not getting instantiated and if it does I cannot access any of its public variables i.e. stage instances!!!

All I want to do here is load a movie clip asset from a swf library and the dynamically associate it with a custom class?

Any thoughts or code tips would be greatly appreciated…

Comments