2 Replies Latest reply on Jan 11, 2011 8:31 AM by Roland684

    How to reference the stage from within a class?


      I'm trying to get a small popup (a volume bar) to work from within a class.

      I made a piece of actionscript code that creates an empty movieClip and draws the bar into it and made it onto a class. The only thing I now have to do to add the bar to a programm, is create an instance of that class. Nothing needs to be added to the stage.


      The problem I encounter is that I need the bar to stay on top. New movieclips always get higher depths (using getNextHighestDepth()), so that's a problem.

      Calling swapDepths() for every new movieclip is far too complex and afaik there is no such thing as "bring to front" in actionscript, it only exists at design time, not at runtime.


      So I though I'd use 2 layers/movieclips in the timeline, one for the volume bar and one for the rest, and add an empty movieclip to both.

      This way I know that all children I add to one movieclip will alway lay below anything I add to the second movieclip. (or is there an easier way to accomplish what I need? Levels maybe? I've never looked into levels, I only know they exist when loading a clip)

      This means I need to add a some extra stuff to the stage at design time, but if this fixes the issue.. ah well.


      But how can I access that movieclip from within a class? The reference "_root.volumeBarPlaceholder" works from within the main actionscript, but not from within a class because I get the compiler error "There is no property with the name '_root.volumeBarPlaceholder'";


      Also I'm not sure where anything I create/attach to _root will end up. Is _root allways the lowest level/depth (0?) or is it created when actionscript starts and on top of anything created at design time?