Visit SlideShowPro.net  Community Forums
SlideShowPro Help Wiki
  

SlideShowPro for Flash

How to: Dynamically assign an XML file

These instructions will show how to dynamically assign both the xmlFilePath and xmlFileType parameters through the Flash player embed code. This allows you to change slideshow content without publishing a new SWF. Here's how.

Step One: 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 Two: 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="xmlfile=http://mydomain.com/myXML.xml&xmlfiletype=Default" />

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

<embed FlashVars="xmlfile=http://mydomain.com/myXML.xml&xmlfiletype=Default" ... (other attributes)>

Step Three (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','xmlfile=http://mydomain.com/myXML.xml&xmlfiletype=Default'

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 Four: 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 (xmlfile) { my_ssp.xmlFilePath=xmlfile; }
if (xmlfiletype) { my_ssp.xmlFileType=xmlfiletype; }

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 == "xmlfile") {
      my_ssp.xmlFilePath = paramObj[param];
   }
   if (param == "xmlfiletype") {
      my_ssp.xmlFileType = paramObj[param];
   }
}

That’s it! Publish, and open your HTML document in a web browser. Your data should now be dynamically assigned.

Page last modified by afrmx on April 21, 2009, at 05:19 PM
© 2010 Dominey Design Inc. All Rights Reserved.
About | Merchandise | Contact | Privacy policy | Legal | Licensing