Say I’ve got a utility class in which I would like to access the stage (in order to get the frameRate).
I don’t particularly want to force the user to pass in the stage to each method or set a static property on my class before using it.
Is there any way to get ahold of the stage without it being passed in? All I need is the frameRate!
set the framerate as a public static variable or public constant in your main document class (or where ever else a reference to the stage is available) then call that static variable from your utility class:
Document Class
Utility Class
[EDIT]:
in your case where you don’t have direct access to the stage you could have your users pass the
stage.frameRatevalue to the constructor of your utility class, but i’m sure you will agree this approach isn’t very elegant. i think that your idea to measure the intervals between ENTER_FRAME events is the best solution.