Selteco.com > FlashDesignerZONE.com > Tutorials > T1041

Use FSCommand with the browser.

SYMPTOMS

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

SOLUTION

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="http://active.macromedia.com/flash5/cabs/swflash.cab#version=5,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="flash.swf" WIDTH="640" HEIGHT="480" PLAY="true" LOOP="true" 
WMODE="opaque" NAME="flashMovie" QUALITY="high" swliveconnect=true 
PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?
P1_Prod_Version=ShockwaveFlash">
</EMBED>
</OBJECT>

NOTE:

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

Download source project t1041.zip (9 kb)

Creating "Close" button

  1. Choose "Insert" > "Symbol" command
  2. Choose the following symbol from "Wingding" list:

  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.

Products | Purchase | Downloads | Support | Flash Tutorials | Contact
Copyright © 1999-2017 Selteco Software, Inc. www.selteco.com, ph: +1 810 377 5778