Passing parameter from HTML to Flash in Adobe CS4

Suppoe we need pass the video name from HTML to Flash.

1.   Add the following  ActionScript into FLA:

# Display the video in 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);

#  myVIDEO is the parameter from HTML
if (myVIDEO == undefined) {
myTxt.text = “Keynote_1.flv”;
} else {
myTxt.text = myVIDEO;
}

// create basic netConnection object
var nc:NetConnection = new NetConnection();

// connect to the local Red5 server
nc.connect(“rtmp://192.168.127.127/oflaDemo”);

// create the netStream object and pass the netConnection object in the constructor
var ns:NetStream = new NetStream(nc);

// attach the netStream object to the video object
videoContainer.attachVideo(ns);

// Play the video
ns.play(myTxt.text);

 

 

2.  Generate the SWF and HTML from FLA

 

 

3. Modify the generated HTML to add myVIDEO parameter,

   Three parts to be modified in HTML:

 

   A)  Add the following line in the  AC_FL_RunContent block:

       ‘FlashVars’,’myVIDEO=Keynote_2.flv’,

 

  B)  Add the following line in the  Object block:

      <param name=”FlashVars” value=”myVIDEO=Keynote_2.flv” />

 

  C)  Add the following into the embed scr block:

     FlashVars=”myVIDEO=Keynote_2.flv”

 

http://commondatastorage.googleapis.com/red5.zhenglei.net/Pass_Variable_From_Html_To_Flash.7z