> > Tutorials > T1041

Use FSCommand with the browser.


FScommand doesn’t work when the movie plays in a browser. FScommand works only with Macromedia standalone projector.

This tutorial describes how to create a “quit button” and use fscommand to communicate with the browser

Example of fscommand:quit


Step 1:

Add the following JavaScript handler to your HTML page:

<SCRIPT LANGUAGE=JavaScript><!--function flashMovie_DoFSCommand(command, args) {  if (command == "quit")  {    window.opener=self;window.close();  }}//--></SCRIPT><SCRIPT LANGUAGE="VBScript"><!-- Sub flashMovie_FSCommand(ByVal command, ByVal args)  call flashMovie_DoFSCommand(command, args)end sub}//--></SCRIPT>

Step 2:

Open your Flash Designer project and program the button. Select the button and choose “Action” > “OnClick”. To execute FScommand use one of the following methods:

Get URL option

ActionScript option

Step 3:

Export SWF file with “File” > “Export Flash SWF File” command. Choose “File” > “View HTML Code” copy the code and paste it to your HTML page.

Modify the code and add ID (flashMovie) to the OBJECT and EMBED tags and swfliveconnect option to EMBED:

<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ID="flashMovie"WIDTH="640" HEIGHT="480"CODEBASE=",0,0,0"><PARAM NAME="MOVIE" VALUE="flash.swf"><PARAM NAME="PLAY" VALUE="true"><PARAM NAME="LOOP" VALUE="true"><PARAM NAME="WMODE" VALUE="opaque"><PARAM NAME="QUALITY" VALUE="high"><EMBED SRC="" WIDTH="640" HEIGHT="480" PLAY="true" LOOP="true" WMODE="opaque" NAME="flashMovie" QUALITY="high" swliveconnect=true PLUGINSPAGE=""></EMBED></OBJECT>


In xxxxx_DoFSCommand(command, args) handler “command” will be the string after FSCommand: and “args” is the target argument

Download source project (9 kb)

get flash

Creating “Close” button

  1. Choose “Insert” > “Symbol” command
  2. Choose the following symbol from “Wingding” list:insert symbol
  3. Choose “Action” > “OnClick”
  4. Choose “Get URL” action and enter the code:FSCommand:quit

    Click OK

  5. Choose “Action” > “On Over Color”, uncheck “No Color” and select your favorite color, click OK

NOTE: The button will work in HTML page only. It doesn’t work in preview mode because there is no javascript code to communicate with.