StageReference
| Kind of class: | public class |
|---|---|
| Package: | org.casalib.util |
| Inherits from: | none |
| Version: | 09/06/09 |
| Author: | Aaron Clinger |
| Classpath: | org.casalib.util.StageReference |
| File last modified: | Sunday, 06 September 2009, 08:45:20 |
Stores a reference to Stage for classes that cannot easily access it. This class allows you to stored multiple references by ID to different
Stage}s 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 org.casalib.display.CasaMovieClip; import org.casalib.util.StageReference; public class MyExample extends CasaMovieClip { public function MyExample() { super(); StageReference.setStage(this.stage); trace(StageReference.getStage().stageWidth); } } }
Summary
Constants
- STAGE_DEFAULT : String
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
nullif 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
trueif the Stage reference was found and removed; otherwisefalse.
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.