Dynamically loaded SWF instance names missing

Hi,

I have loaded an externally .SWF (son.swf) file inside my movie (parent.swf).

son.swf has 2 objects inside its library:
Character (Base Class = “flash.display.Sprite”, Class = “Character”)
CharacterHead (Base Class = “flash.display.Sprite”, Class = “CharacterHead”)

The “Character” object has inside 1 instance of “CharacterHead” and “CharacterHead” does not have a instance name asociated with it.

This is something like what i have got so far inside parent.swf :

[AS]
var ipAddress:String = “NNN.NNN.N.NNN” // not important
var loadedSwf:Array = [“http://” + ipAddress + “/games/CH000.SWF”, null]

var loader:Loader = new Loader();

// Lets suppouse its going to always load it for this example
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onSWFLoadedOk);

var peticion:URLRequest = new URLRequest(loadedSwf[0]);
loader.load(peticion);

function onSWFLoadedOk(e:Event):void{
loadedSwf[1] = e.target
}

var lodInfo:LoaderInfo = loadedSwf[1]

var classObject:Class = lodInfo.applicationDomain.getDefinition(“CharacterImage”) as Class
var newSprite:Sprite = new classObject() as Sprite;

var i:int
for(i=0;i< newSprite.numChildren;i++){
trace(newSprite.getChildAt(i))
/* trace “[object MovieClip]”
i need it to trace “[object CharacterHead]”
*/
}

[/AS]

So, i need it to trace the class attribute not the extended Class but seems like its lost when i load it.

NOTES:

  1. If i create and use a function from son.swf Class it still give me the same problem when i invoke it from the parent.swf .

  2. If i create an instance of “Character” inside the constructor function of son.swf and then i trace the childs names it will give them as they have to be ("[object CharacterHead]").

  3. If i set an instance name to the instance of “CharacterHead” inside “Character” then i cant load the son.swf. it throws Error #1034 Cant convert flash.display::MovieClip@1c183919 to CharacterHead
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at Character()
    (…)
    at CHMain/getSpriteData()[F:\wamp\games\CHMain.as:20]
    at CHMain/getSWFSprite()[F:\wamp\games\CHMain.as:16]
    /*

the error is related to this line of code
var newSprite:Sprite = new classObject() as Sprite;

*/

So i need it to trace the class (not the Base Class that it extends) when instanciated from the parent.swf

Thanks, and sorry if i misspelled some words.