LocationUtil

Kind of class:public class
Package:org.casalib.util
Inherits from:none
Version:03/03/08
Author:Aaron Clinger
Classpath:org.casalib.util.LocationUtil
File last modified:Thursday, 19 February 2009, 11:33:37
Utilities for determining the location of the SWF and the type of runtime environment.

Summary


Class methods
  • isWeb (location:DisplayObject) : Boolean
    • Determines if the SWF is being served on the internet.
  • isDomain (location:DisplayObject, domain:String) : Boolean
    • Detects if MovieClip's embed location matches passed domain.
  • getDomain (location:DisplayObject) : String
    • Detects MovieClip's domain location.
  • isPlugin : Boolean
    • Determines if the SWF is running in a browser plug-in.
  • isIde : Boolean
    • Determines if the SWF is running in the IDE.
  • isStandAlone : Boolean
    • Determines if the SWF is running in the StandAlone player.
  • isAirApplication : Boolean
    • Determines if the runtime environment is an Air application.

Class methods

getDomain

public static function getDomain (
location:DisplayObject) : String

Detects MovieClip's domain location.
Parameters:
location:
MovieClip to get location of.
Returns:
  • Returns full domain (including sub-domains) of MovieClip's location.
Usage:
  • trace(LocationUtil.getDomain(_root));
Usage note:
  • Function does not return folder path or file name. The method also treats "www" and sans "www" as the same; if "www" is present method does not return it.

isAirApplication

public static function isAirApplication (
) : Boolean

Determines if the runtime environment is an Air application.
Returns:
  • Returns true if the runtime environment is an Air application; otherwise false.

isDomain

public static function isDomain (
location:DisplayObject, domain:String) : Boolean

Detects if MovieClip's embed location matches passed domain.
Parameters:
location:
MovieClip to compare location of.
domain :
Web domain.
Returns:
  • Returns true if file's embed location matched passed domain; otherwise false.
Usage:
  • To check for domain:
    trace(LocationUtil.isDomain(_root, "google.com"));
    trace(LocationUtil.isDomain(_root, "bbc.co.uk"));

    You can even check for subdomains:
    trace(LocationUtil.isDomain(_root, "subdomain.aaronclinger.com"))

isIde

public static function isIde (
) : Boolean

Determines if the SWF is running in the IDE.
Returns:
  • Returns true if SWF is running in the Flash Player version used by the external player or test movie mode; otherwise false.

isPlugin

public static function isPlugin (
) : Boolean

Determines if the SWF is running in a browser plug-in.
Returns:
  • Returns true if SWF is running in the Flash Player browser plug-in; otherwise false.

isStandAlone

public static function isStandAlone (
) : Boolean

Determines if the SWF is running in the StandAlone player.
Returns:
  • Returns true if SWF is running in the Flash StandAlone Player; otherwise false.

isWeb

public static function isWeb (
location:DisplayObject) : Boolean

Determines if the SWF is being served on the internet.
Parameters:
location:
DisplayObject to get location of.
Returns:
  • Returns true if SWF is being served on the internet; otherwise false.
Usage:
  • trace(LocationUtil.isWeb(_root));