Skip to content

Instantly share code, notes, and snippets.

@rafaelrinaldi
Created March 2, 2011 00:38
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 rafaelrinaldi/850221 to your computer and use it in GitHub Desktop.
Save rafaelrinaldi/850221 to your computer and use it in GitHub Desktop.
Easy way to check if the application is running online or locally.
package tea.util
{
import tea.util.isStandalone;
import flash.display.DisplayObjectContainer;
/**
*
* Easy way to check if the application is running online or locally.
*
* @param p_root Application root.
* @return True if isn't running standalone and current application protocol is http:// or https://, false otherwise.
*
* */
public function isPublished( p_root : DisplayObjectContainer ) : Boolean
{
if(isStandalone()) return false;
if(p_root.loaderInfo == null) return false;
const loaderURL : String = p_root.loaderInfo.loaderURL;
return Boolean(loaderURL.split("http://").length != 1) || Boolean(loaderURL.split("https://").length != 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment