Packagecitrus.utils
Classpublic class LevelManager
InheritanceLevelManager Inheritance Object

The LevelManager is a complex but powerful class, you can use simple states for levels with SWC/SWF/XML.

Before using it, be sure that you have good OOP knowledge. For using it, you must use an Abstract state class that you give as constructor parameter : Alevel.

The six ways to set up your level :

An instantiation example in your Main class (you may also use the AGameData to store your levels) : levelManager = new LevelManager(ALevel); levelManager.onLevelChanged.add(_onLevelChanged); levelManager.levels = [Level1, Level2]; levelManager.gotoLevel();

The _onLevelChanged function gives in parameter the Alevel that you associate to your state : state = lvl; Then you can associate other functions :

And their respective actions :

The ALevel class must implement public var lvlEnded and restartLevel Signals in its constructor. If you have associated a SWF or SWC file to your level, you must add a flash MovieClip as a parameter into its constructor, or a XML if it is one!



Public Properties
 PropertyDefined By
  applicationDomain : ApplicationDomain = null
If you want to load your SWF level on iOS, set it to ApplicationDomain.currentDomain.
LevelManager
  checkPolicyFile : Boolean = false
LevelManager
  currentIndex : uint
[read-only]
LevelManager
  currentLevel : Object
LevelManager
  enableSwfCaching : Boolean = false
If set to true, and the level comes from an SWF, the SWF is only loaded once, then cached.
LevelManager
  levels : Array
LevelManager
  nameCurrentLevel : String
[read-only]
LevelManager
  onLevelChanged : Signal
LevelManager
  securityDomain : SecurityDomain = null
LevelManager
Public Methods
 MethodDefined By
  
LevelManager(ALevel:Class)
LevelManager
  
destroy():void
LevelManager
  
[static]
LevelManager
  
gotoLevel(index:uint = 0):void
Call the LevelManager instance's gotoLevel() function to launch your first level, or you may specify it.
LevelManager
  
nextLevel():void
LevelManager
  
prevLevel():void
LevelManager
Property Detail
applicationDomainproperty
public var applicationDomain:ApplicationDomain = null

If you want to load your SWF level on iOS, set it to ApplicationDomain.currentDomain.

checkPolicyFileproperty 
public var checkPolicyFile:Boolean = false

currentIndexproperty 
currentIndex:uint  [read-only]


Implementation
    public function get currentIndex():uint
currentLevelproperty 
public var currentLevel:Object

enableSwfCachingproperty 
public var enableSwfCaching:Boolean = false

If set to true, and the level comes from an SWF, the SWF is only loaded once, then cached. Enable this if you plan to deliver an IOS app, since IOS does not support SWF reloading in AOT (build) mode.

levelsproperty 
public var levels:Array

nameCurrentLevelproperty 
nameCurrentLevel:String  [read-only]


Implementation
    public function get nameCurrentLevel():String
onLevelChangedproperty 
public var onLevelChanged:Signal

securityDomainproperty 
public var securityDomain:SecurityDomain = null

Constructor Detail
LevelManager()Constructor
public function LevelManager(ALevel:Class)



Parameters
ALevel:Class
Method Detail
destroy()method
public function destroy():void

getInstance()method 
public static function getInstance():LevelManager

Returns
LevelManager
gotoLevel()method 
public function gotoLevel(index:uint = 0):void

Call the LevelManager instance's gotoLevel() function to launch your first level, or you may specify it.

Parameters

index:uint (default = 0) — the level index from 1 to ... ; different from the levels' array indexes.

nextLevel()method 
public function nextLevel():void

prevLevel()method 
public function prevLevel():void