Return to Snippet

Revision: 9982
at December 2, 2008 11:29 by chrisaiv


Initial Code
public function SlideShow( ){
     //If you are working locally on your computer, you will load manually load the xml file.  Otherwise you will be receiving the xml file from SWFObject2
     xmlURL = ( getDevelopmentMode() === "Production" ) ? getFlashVars().xml : "./xml/data.xml";

     //Capture where the SWF is living on the live site
     var currentLocationOfSWF:String = getContextPath();
}

private function getFlashVars():Object
{
     return Object( LoaderInfo( this.loaderInfo ).parameters );
}

private function getDevelopmentMode():String
{
	var dev:Boolean = new RegExp("file://").test( this.loaderInfo.loaderURL);

	if( dev ) return "Development";
	else return "Production";
}

private function getContextPath():String
{
	var uri:String = getLoaderURL();
	return uri.substring(0, uri.lastIndexOf("/")) + "/";
}

private function getLoaderURL():String
{
	return this.loaderInfo.loaderURL;
}

Initial URL

                                

Initial Description
These are my favorite helper functions.   getFlashVars() is used to quickly pull out variables from SWFObject2, getDevelopmentMode() is used to determine whether you are working locally on your machine or if the SWF is hosted on a server,  getContextPath() is used to determine what directory the SWF is located

Initial Title
AS3: My favorite helper functions

Initial Tags

                                

Initial Language
ActionScript 3