ActionScript 3.0 Design Patterns

(Chris Devlin) #1
Decorating with Deadly Sins and Heavenly Virtues | 163

In looking at the script, all it does is pass the three different values generated by the


getter methods,good( ),evil( )andgetSoul( ), to thesetAngelDevil( )function. The


setAngelDevil( )function uses two movie clips from the library and positions them


on the stage. Depending on the outcome, the concrete component’s name appears in


the angel or devil icon. Figure 4-7 shows what the output will look like. Use it as a


guide for setting up your stage.


var booRight:Number=Number(right>0);
devil.x=330;
devil.y=270-((wrongbooWrong)(270/72));
angel.x=96;
angel.y=270-((rightbooRight)(270/60));
if (booWrong)
{
devil.soul_txt.text=eternalsoul;
} else
{
angel.soul_txt.text=eternalsoul;
}
}
}
}


Figure 4-7. Decorator generated values used for placement and labels


Example 4-37. Soul.as (continued)

Free download pdf