Modifying Library Assets at Runtime

Hey guys,

Overview:
I’m building an avatar class that will allow a user to swap out character assets during runtime. The idea is pretty straight forward. The artist I am working with designed the art assets for the individual pieces of the avatar and performed the animations in flash. Since the animations were created in flash using vector art as opposed to pre-rendered 3d, I want to simply replace each individual movieclip within the animation with the asset selected by the player.

Problem:
The issue i’m running into is that the animations have several key frames. My thought is to load the avatar object (an external swf) into my main application. Once loaded, I obtain a reference to all library assets that are used in the animations. For example, to get the face, I have something like:


if(this.loaderInfo.applicationDomain.hasDefinition("face"))
{
	var assetClass:Class = this.loaderInfo.applicationDomain.getDefinition("face) as Class;
}

In the code above, assetClass refers to an exported movieclip in my library. This statement works fine, but the problem is, how can I modify this class object during runtime? The idea is that, if assetClass is the class definition for the “face” movieclip, I could simply treat assetClass as a MovieClip and call “addChild” to add the users selected face (an external swf of just the face that will be loaded during runtime) to this movieclip. Since it’s adding it to the class definition, it would then update all keyframes on the timeline such that any instance of the face movieclip is instantiated with the new face image. I’m sure there is a way to do this, but I haven’t found any documentation on it. This will allow me to treat my avatar as an animation skeleton basically such that I can swap out assets at anytime during runtime, giving the desired animation effect. If you have any information on how to do this, please point me in the right direction. Thanks!

Regards,

Will