I am trying to add sound from library. Like
backGroundSound:Sound = new BackGroundSound();
// BackGroundSound is mp3 file class name.
I want to use this as common for all developers who use Backgroundsound for their game.
I want to check before adding it like whether it is exported in library to prevent compilation error.
Please help me to solve this problem.
Try the following:
var classExist:Boolean = isClassExists("BackGroundSound");
private function isClassExists(className:String, domain:ApplicationDomain = null):Boolean
{
var res:Boolean;
if(domain)
{
res = domain.hasDefinition(className);
}
else
{
res = getDefinitionByName(className);
//or the same
//res = ApplicationDomain.currentDomain.hasDefinition(className);
}
return res;
}