Comparing Class names

In the most recent project I've been developing I've needed to match up or pair a class name with an identifier from an XML file. Something like this:

<spriteID>SomeClass</spriteID>
[object SomeSprite]

A possible solution to achieve this is demonstrated pseudo code below.

var stageSprite:Object = stageSprit;
var stageSpriteClass:Object = Object(stageSprite).constructor;
var xmlClassName:Object = getDefinitionByName(xmlSpriteID);

if(stageSpriteClass == xmlClassName){
   return true;
}

 Usually you can achieve this dynamically without the need to to compare and associate clips but in case you need to do it this way, you now know how.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Related posts

Comments are closed