/ Published in: ActionScript 3
                    
                                        
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
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
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;
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                