Getting custom class names of nested MCs from SWF

Hi,
I’m using mcs from my swf library as simple level templates and need to read custom class names of nested objects.
This worked pretty well until I updated Haxe, OpenFl and Lime to recent versions.

var obj:Dynamic = levelDesign.getChildAt(i);
var oType:String = Type.getClassName(Type.getClass(obj));

Now it returns openfl.display.MovieClip instead of custom class names.

Am I missing something? Nothing I found on the internet seemed to work, and as it’s super convenient, I wouldn’t like to use instance names…

custom_class

1 Like

I think this is something related to what you are looking for:

Thank you! Yes, seems to be a similar problem and helped a lot to look at the right spots.
But I think the information is already there and we just need a proper way to get it…?
When iterating over 9 nested mcs, this

		/* if(Std.isOfType(obj, Door)){
			Log.debug("Yay, I found a door!");
		} */
		Log.debug("oType: " + Type.getClassName(Type.getClass(obj)));

returns 9 x “oType: openfl.display.MovieClip” (like also Lib.getQualifiedClassName(obj); etc.).
But this

		if(Std.isOfType(obj, Door)){
			Log.debug("Yay, I found a door!");
		}
		Log.debug("oType: " + Type.getClassName(Type.getClass(obj)));

returns not only “Yay, I found a door!”, but also 1x “oType: Door” (!) and 8 x “oType: openfl.display.MovieClip”.

Any ideas what’s happening here, and what could be a better way to access custom classes instead of type testing each of them with Std.isOfType()…? :smile:

Beckwahn, access to class names in an swf was broken earlier, in 2020. As far as I know, there is no convenient solution so far. Perhaps, you might find some useful stuff here: Dynamic assets creation by full class name from swf library is broken

Yes, thank you. I also read this post and went to using the classes stored in the “_generated” folder after the first compilation.