# Dynamically loaded SWF instance names missing

**URL:** <https://forum.kirupa.com/t/dynamically-loaded-swf-instance-names-missing/316659>\
**Category:** flash\
**Created:** [November 29, 2010, 6:24am UTC](https://forum.kirupa.com/t/dynamically-loaded-swf-instance-names-missing/316659 "2010-11-29T06:24:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eduardof\_2010](https://avatars.discourse-cdn.com/v4/letter/e/958977/32.png) [@eduardof\_2010](https://forum.kirupa.com/u/eduardof_2010)\
**Post date:** [November 29, 2010, 6:24am UTC](https://forum.kirupa.com/t/dynamically-loaded-swf-instance-names-missing/316659/1 "2010-11-29T06:24:55Z")

</div>

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.
