« back

Fleb Framework: Global variables

In the Fleb Framework, a very simple but efficient singleton class for handling global variables is used: VarCentral. You can easily use it for your own purpose, add any value (string, object, array… whatever) and access it from anywhere in your project.

Example

// import the class
import net.kaegi.utils.VarCentral
// add a value
VarCentral.getInstance().vars = {foo:"bar"}
// use value
trace(VarCentral.getInstance().vars.foo)
// returns "bar"

If you are lazy like me and don't want to re-type “VarCentral.getInstance().vars….” all the time you can use this shortcut:

// import the class
import net.kaegi.utils.VarCentral
// shortcut
var varcentral:Object = VarCentral.getInstance().vars
// add some values
varcentral.foo = "bar";
varcentral.foo2 = "test";
varcentral.blabla = "gugus";

Now you can use these values from anywhere in your project (e.g. another SWF):

// import the class
import net.kaegi.utils.VarCentral
// shortcut
var varcentral:Object = VarCentral.getInstance().vars
// use values
trace(varcentral.foo)
trace(varcentral.foo2)
trace(varcentral.blabla)
// returns:
// "bar"
// "test"
// "gugus"

Reserved variable names

You should not overwrite the following global variables used by the Fleb Framework itself. But it is easy to avoid it, they all start with “fleb”. They are listed here in two groups: the first one you may use for your own purpose and the second one which you will probably never use directly.

Fleb global variables you may want to use

varcentral.flebEvents

Initialised in net.kaegi.utils.VarCentral
Central event system. More infos here.

varcentral.flebBase

Initialised in net.kaegi.fleb.Startup
Use this variable to directly access public methods you may have created in Base.as

varcentral.flebPreloader

Initialised in net.kaegi.fleb.Startup
The preloader movieclip is stored in this variable.

varcentral.flebLanguage

Initialised in net.kaegi.fleb.Startup
Stores the language code.

varcentral.flebStage

Initialised in net.kaegi.fleb.Startup
Stores a reference to the stage object.

varcentral.flebMain

Initialised in net.kaegi.fleb.Core
Use this variable to directly access public methods you have created in Main.as

varcentral.flebPageHolder

Initialised in net.kaegi.fleb.Core
Stores a reference to the sprite/movieclip that holds the loaded content pages.

varcentral.flebNavigationHolder

Initialised in net.kaegi.fleb.Core
Stores a reference to the sprite/movieclip that holds the global navigation.

varcentral.flebNavigationManager

Initialised in net.kaegi.fleb.Core
Stores a reference to the global navigation manager class.

varcentral.flebFontManager

Initialised in net.kaegi.fleb.Core
Stores a reference to the font manager class. There is only one public method available: getStyleSheet()

varcentral.flebActiveID

Initialised in net.kaegi.fleb.Core
Stores the button ID of the currently active content page (defined in structure.xml)

varcentral.flebPreviousID

Initialised in net.kaegi.fleb.Core
Stores the button ID of the previously active content page (defined in structure.xml)

varcentral.flebActiveData

Initialised in net.kaegi.fleb.Core
Stores the data object of the currently active content page (defined in structure.xml):

  • data.swfArr
  • data.sourceArr
  • data.titleArr
  • data.addressArr

The arrays (swfArr etc.) contain 5 values for 5 languages. For example, if varcentral.flebLanguage is 2, then the third element of the arrays will be used.

varcentral.flebPreviousData

Initialised in net.kaegi.fleb.Core
Stores the data object of the previously active content page (defined in structure.xml):

varcentral.flebActiveBtn

Initialised in net.kaegi.fleb.Core
Stores a reference to the currently active NavigationButton2.

varcentral.flebPreviousBtn

Initialised in net.kaegi.fleb.Core
Stores a reference to the NavigationButton2 that was active before the current button.

varcentral.flebActivePage

Initialised in net.kaegi.fleb.PageLoader
Stores a reference to the currently active content page.

varcentral.flebPreviousPage

Initialised in net.kaegi.fleb.PageLoader
Stores a reference to the previously active content page.

varcentral.flebCore

Initialised in net.kaegi.fleb.Core
Stores a reference to net.kaegi.fleb.Core

Fleb global variables you will probably never use

varcentral.flebStartup

Initialised in net.kaegi.fleb.Startup

fleb-framework-global-variables.txt · Last modified: 2011/11/11 18:55 (external edit)
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki