Created
March 2, 2011 00:38
-
-
Save rafaelrinaldi/850221 to your computer and use it in GitHub Desktop.
Easy way to check if the application is running online or locally.
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 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