You're referring to static
members.
Your class SoundHandler
would have a static method called playSound()
, which can be implemented like so:
package
{
public class SoundHandler
{
public static function playSound():void
{
// @todo Logic
}
}
}
Your playSound()
method is now accessible via:
SoundHandler.playSound();
Note: You mentioned global methods being bad, however this is a perfect candidate for these and something I would actually recommend (as much as I hate using static).
Additional: ActionScript 3's Math
class contains mostly static members e.g. Math.round()
Your question (comment): Do I need to initiate SoundHandler
in the document class?
No, in fact you shouldn't make an instance of SoundHandler at all. The only requirement is that you must have SoundHandler
imported in your current class to access it:
import yourpackage.SoundHandler;