Created
October 13, 2012 20:07
-
-
Save nilocesar/3885960 to your computer and use it in GitHub Desktop.
globalvar for AS3 by D3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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