StageReference

Kind of class:public class
Package:org.casalib.util
Inherits from:none
Version:01/19/09
Author:Aaron Clinger
Classpath:org.casalib.util.StageReference
File last modified:Wednesday, 04 February 2009, 15:00:38
Stores a reference to Stage for classes that cannot easily access it. This class allows you to stored multiple references by ID to different Stages which is helpful in an AIR environment.
Usage note:
  • You must first initialize the class by setting a reference to Stage. See example below:
Example:
  • package {
        import flash.display.MovieClip;
        import org.casalib.util.StageReference;
    
    
        public class MyExample extends MovieClip {
    
    
            public function MyExample() {
                super();
    
                StageReference.setStage(this.stage);
    
                trace(StageReference.getStage().stageWidth);
            }
        }
    }

Summary


Constants
Class methods
  • getStage (id:String = StageReference.STAGE_DEFAULT) : Stage
    • Returns a reference to Stage.
  • setStage (stage:Stage, id:String = StageReference.STAGE_DEFAULT) : void
    • Stores a reference to Stage.
  • removeStage (id:String = StageReference.STAGE_DEFAULT) : Boolean
    • Removes a stored reference to a Stage.
  • getIds : Array
    • Finds all the Stage reference ids.
  • getStageId (stage:Stage) : String
    • Finds the identifier for a stored Stage reference.

Constants

STAGE_DEFAULT

public static const STAGE_DEFAULT:String = 'stageDefault'
(read)

Class methods

getIds

public static function getIds (
) : Array

Finds all the Stage reference ids.
Returns:
  • An Array comprised of all the Stage reference identifiers.

getStage

public static function getStage (
id:String = StageReference.STAGE_DEFAULT) : Stage

Returns a reference to Stage.
Parameters:
id:
The identifier for the Stage instance.
Returns:
  • The Stage instance.
Throws:
  • Error if you try to get a Stage that has not been defined.

getStageId

public static function getStageId (
stage:Stage) : String

Finds the identifier for a stored Stage reference.
Parameters:
stage:
The Stage you wish to find the identifier of.
Returns:
  • The id for the stored Stage reference or null if it doesn't exist.

removeStage

public static function removeStage (
id:String = StageReference.STAGE_DEFAULT) : Boolean

Removes a stored reference to a Stage.
Parameters:
id:
The identifier for the Stage.
Returns:
  • Returns true if the Stage reference was found and removed; otherwise false.

setStage

public static function setStage (
stage:Stage, id:String = StageReference.STAGE_DEFAULT) : void

Stores a reference to Stage.
Parameters:
stage:
The Stage you wish to store.
id :
The identifier for the Stage.