First of all, why the heck would you want to do this? A couple of reasons:
- It gives the ability for someone else to modify the Flash content without knowing Flash!
- It keeps you from making many different swfs for projects that are highly similar. i.e. If you need to create many different video players because they’re all going to play different clips. Well, just make the content path to the video a variable in HTML!
Here’s how you do it:
In HTML, add this parameter to your embedded swf object:
value=”videoName=testVideo1″ name=”FlashVars”
If you wanted to add more parameters you’d write it this way:
value=”videoName=testVideo1&theLogo=kentwood” name=”FlashVars”
ÂÂ
In Flash, create a Flash File - ActionScript 3.
In the first frame place two dynamic text fields with the name videoNameText and theLogoText on the stage.
Add this code in your Actions panel.ÂÂ
this.loaderInfo.addEventListener(Event.COMPLETE, loaderComplete);
function loaderComplete(myEvent:Event) {
  var flashVars=this.loaderInfo.parameters;
  videoNameText.text = "videoName from HTML: " + flashVars.videoName;
  theLogoText.text = "theLogo from HTML: "+flashVars.theLogo;
}
Publish your swf and HTML.ÂÂ
Place the HTML parameters in the HTML code.
Preview in Browser. You should see the following in the text fields
videoName from HTML: testVideo1
theLogo from HTML: kentwood
With what you’ve learned above you’re able to control content in Flash from HTML! Very handy.