So I have my function characterBooleanFunction which holds over 30 if-else statements. When I run Scout to check performance it points right to this function which is also ran by a ENTER_FRAME event. Scout is showing me that the gotoAndStop statement is being very costly. I'm not sure how to fix this everytime I run the game it just laggs horribly. The user scrolls the characters on the screen and when they hit a mark it activates the characterBooleanFunction function. Any ideas? Here is the code:
private function characterBooleanFunction():void
{
if (scrollCharacters.mcRandom.hit.hitTestObject(storeScreen.mcMarker) )
{
scrollCharacters.mcRandom.gotoAndStop(2);
//booleans
bRandom = true;
}else
{
scrollCharacters.mcRandom.gotoAndStop(1);
bRandom = false;
}
if (scrollCharacters.mcChinese.hit.hitTestObject(storeScreen.mcMarker) )
{
scrollCharacters.mcChinese.gotoAndStop(2);
trace("HIT CHINESE");
//booleans
bChinese = true;
}else
{
scrollCharacters.mcChinese.gotoAndStop(1);
bChinese = false;
}
if (scrollCharacters.mcPizza.hit.hitTestObject(storeScreen.mcMarker) )
{
scrollCharacters.mcPizza.gotoAndStop(2);
trace("HIT PIZZA");
//booleans
bPizza = true;
}else
{
scrollCharacters.mcPizza.gotoAndStop(1);
bPizza = false;
}
if (scrollCharacters.mcBurger.hit.hitTestObject(storeScreen.mcMarker) )
{
scrollCharacters.mcBurger.gotoAndStop(2);
//booleans
bBurger = true;
}else
{
scrollCharacters.mcBurger.gotoAndStop(1);
bBurger = false;
}
... so on and so on.
Thanks in advance!