Passing Variables from HTML to Flash in Adobe CS4

Suppose we need to pass the currnet URL from HTML to Flash:

 

1.   Add the following  ActionScript into FLA:

# #  myVIDEO is the parameter from HTML,  and we display it on screen

var my_fmt = new TextFormat();
my_fmt.color = 0xFF0000;
my_fmt.underline = true;
this.createTextField(“myTxt”, 1, 320, 10, 200, 20);
myTxt.autoSize = “left”;
myTxt.setTextFormat(my_fmt);

if (myVIDEO == undefined) {
myTxt.text = “Keynote_1.flv”;
} else {
myTxt.text = myVIDEO;
}

 

2.  Generate the SWF and HTML from FLA

 

 

3. Modify the generated HTML to add myVIDEO parameter,

   3.1 ==> Add the following line in the  AC_FL_RunContent block:

       ‘flashvars’,”,

 

   3.2 ==> Add the handle of flashvars in function AC_GetArgs, as following:

     case “flashvars”:
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = “myVIDEO=”+window.location;
        break;

  // Here myVIDEO the variable in AS2, and window.location is the variable in JavaScript indicating the current URL of HTML page