Visit SlideShowPro.net  Community Forums
SlideShowPro Help Wiki
  

SlideShowPro for Flash

How to: Dynamically assign starting album

These instructions will show how to dynamically assign which album SlideShowPro starts with through the Flash player embed code.

Step One: Assign ID to albums

If you are editing your own XML document and content, open the XML document and add id attributes to each album in your gallery. For example:

<album id="album-1" title="My album" />

If you are using SlideShowPro Director, an ID is automatically published for you. To retrieve the assigned ID of the album you wish to start with, click on the "Albums" tab in Director, then click on the title of the album you want to start with. The album's ID is displayed on the following page.

Step Two: Publish slideshow

With an FLA containing an instance of SlideShowPro on the Stage, publish your movie wherever you like. Flash should create a HTML document and a SWF document. If using Flash CS3 or Flash CS4, you'll also see a JavaScript document. Duplicate the HTML document, and give the duplicate a different name. This way we can make changes without the original HTML document being overwritten by Flash if you republish. When duplicated, open the HTML document in your favorite text editor. Notepad, TextWrangler, Dreamweaver, etc will work fine.

Step Three: Edit param and embed elements

Variables are passed into SWFs using FlashVars. It’s a handy way to pass data into a SWF by editing the parent HTML document embedding it. How your SWF is embedded in the HTML depends on the version of Flash you’re using. All supported versions (Flash MX 2004, Flash 8, Flash CS3, Flash CS4) publish a bundle of object, param, and embed elements. Flash CS3 and CS4 however add an additional embed method using JavaScript, and require an extra step for editing.

Add the following param element before, after, or inbetween any of your existing param elements:

<param name="FlashVars" value="startAlbumID=album-1" />

Next, do this a second time by adding a new FlashVars attribute to your existing embed element:

<embed FlashVars="startAlbumID=album-1" ... (other attributes)>

Step Four (Flash CS3/CS4 only): Edit JavaScript

Flash CS3/CS4 users have an additional step -- modifying the inline JavaScript. Search the HTML document for a method named AC_FL_RunContent, followed by a descending list of comma-separated parameters. Anywhere in that list (the bottom is fine), add the following:

'FlashVars','startAlbumID=album-1'

Make sure when adding this parameter that you include a comma at the end if it is not the last value in the list.

Step Five: Edit FLA

Open the FLA containing SlideShowPro for Flash. Open the Properties panel (Windows > Properties) and give the component instance a unique variable name. For this tutorial, we’ll name it my_ssp.

Now we need to write some ActionScript. Create a new layer in your movie timeline, and click its first frame so it’s highlighted. Open the Actions panel. If you are using the ActionScript 2 version of SlideShowPro, enter the following:

if (startAlbumID) { 
   my_ssp.setStartAlbum(startAlbumID,0);
}

If you are using the ActionScript 3 version, enter this:

var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
for (var param in paramObj) {
   if (param == "startAlbumID") {
      my_ssp.setStartAlbum(paramObj[param],0);
   }  
}

That's it! Publish, and open your HTML document in a web browser. Your slideshow should now begin with the album you've assigned.

Page last modified by tdominey on March 10, 2009, at 07:37 AM
© 2010 Dominey Design Inc. All Rights Reserved.
About | Merchandise | Contact | Privacy policy | Legal | Licensing