Skip to content

Instantly share code, notes, and snippets.

@nilocesar
Created October 13, 2012 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nilocesar/3885960 to your computer and use it in GitHub Desktop.
Save nilocesar/3885960 to your computer and use it in GitHub Desktop.
globalvar for AS3 by D3
package com.includes
{
import flash.external.ExternalInterface;
public class globalVars
{
//=============================================================
// VARIABLES
//=============================================================
// URL
public var urlActual:String;
private var url:String;
private var urlLocal:String = "./";
private var urlWeb:String = "include/swf/";
// CONTAINER
private var container:Array = new Array();
private function setVariables()
{
//
container[ "link" ] = "http://www.google.com.br/";
}
//=============================================================
// PUBLIC FUNCTIONS
//=============================================================
//--------------------------------------
// PUBLIC GET VALUES
//--------------------------------------
public function get( valor )
{
return container[ valor ];
}
//--------------------------------------
// PUBLIC DEBUG MESSAGE
//--------------------------------------
public function debug( text ):void
{
if( ExternalInterface.available )
{
ExternalInterface.call("alert", text);
trace("DEBUG: " + text);
}
}
//--------------------------------------
// CONSTRUCTOR
//--------------------------------------
public function globalVars()
{
// Get URL
getUrl();
// Values
setVariables();
}
//=============================================================
// PRIVATE FUNCTIONS
//=============================================================
//--------------------------------------
// GET URL
//--------------------------------------
private function getUrl()
{
if( ExternalInterface.available )
{
urlActual = ExternalInterface.call("window.location.href.toString");
urlActual == null ? url = urlLocal : url = urlWeb;
}
else
{
url = urlWeb;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment