Home

SWF Scout

SWF Scout screenshot (click to enlarge)



SWF Scout ActiveX/NET library

Download ZIP with the source code (swfscout_fscommand_example.zip, 5 KB)

Flash player control that is used to play flash movies in Internet Explorer, Mozilla and other browsers provides a way to communicate with javascript and flash. To call javascript function from a flash movie you should make the following:

a) set ID parameter of flash player object tag to the some name (for example "myflashmovie"
b) set NAME parameter of flash player embed tag to the same name ("myflashmovie")
c) declare javascript function in HEAD tag section with name. Name of this function should begin with name of your flash movie + DoFSCommand (in our example it will be myflashmovie_DoFSCommand )
So declaration of javascript function will be like this: function myflashmovie_DoFSCommand(command, args) {}
This javascript function will be executed then flash movie will call FSCommand

d) Create a flash movie that will call FSCommand with command and argument parameters that will be passed to the javascript function

Below is a sample flash movie SampleFlash.swf that calls the javascript function when you click a rounded button:

VBScript code that creates SampleFlash.swf flash movie using SWF Scout library is below:

W = 640

H = 480

Set Movie = CreateObject("SWFScout.FlashMovie")

Movie.InitLibrary "demo","demo"

' Movie parameters

Movie.BeginMovie 0,0,W,H,1,12,6

Movie.Compressed = true

Movie.SetBackgroundColor 255,255,255

Font = Movie.AddFont( "Arial",12,true,false,false,false,0)

Text= Movie.AddTextEdit ("mtext","Click button below to call external javascript function",155,0,0,255,Font,30,80,300,200)

Movie.TEXT_ReadOnly= false

Movie.TEXT_NoSelect=false

Movie.TEXT_Align = 0' staLeft align

Movie.TEXT_Multiline = true

Movie.TEXT_WordWrap = true

Movie.PlaceText Text,Movie.CurrentMaxDepth

Shape = Movie.AddShape

Movie.SHAPE_Circle 0, 0, 50

Movie.SHAPE_BeginRadialGradient

Movie.SHAPE_AddRadialGradientColor 255,255,255,255

Movie.SHAPE_AddRadialGradientColor 102,102,102,255

Movie.SHAPE_EndRadialGradient 35,35

Button = Movie.AddButton (false,true)

Movie.BUTTON_AddShape Shape,0

Movie.BUTTON_AddShape Shape,1

Movie.BUTTON_AddShape Shape,2

Movie.BUTTON_AddShape Shape,3

Action= Movie.AddScript

Movie.SCRIPT_GetUrl "FSCommand:call_my_alert", "Hello from flash movie!"

Movie.BUTTON_SetScriptOnEvent 3,Action ' set action on button Release

Movie.PlaceButton Button,Movie.CurrentMaxDepth

Movie.PLACE_SetTranslate 70,250

Movie.ShowFrame 1

Movie.EndMovie

Movie.SaveToFile "SampleFlash.swf"

The source code of ViewFlashWithJavaScript.html is below

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
< HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
< !--
// function should start with myflashmovie_ prefix as we set ID=myflashmovie in object tag and Name="myflashmovie" // in Embed tag below
function myflashmovie_DoFSCommand(command, args) {
if (command == "call_my_alert") {
alert("Message from flash movie: " + args);
}
}
//-->
< /SCRIPT>
<SCRIPT LANGUAGE="VBScript">
< !--
// VB script catches FSCommand too
sub myflashmovie_FSCommand(ByVal command, ByVal args)
call myflashmovie_DoFSCommand(command, args)
end sub
//-->
< /SCRIPT>
< /HEAD>

<BODY>
< OBJECT
CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
WIDTH="100%"
HEIGHT="100%"
CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"
ID=myflashmovie VIEWASTEXT>
<PARAM NAME="MOVIE" VALUE="SampleFlash.swf">
<PARAM NAME="PLAY" VALUE="false">
<PARAM NAME="LOOP" VALUE="false">
<PARAM NAME="QUALITY" VALUE="high">
<PARAM NAME="SCALE" VALUE="SHOWALL">

<EMBED
NAME="myflashmovie"
SRC="SampleFlash.swf"
WIDTH="100%"
HEIGHT="100%"
PLAY="false"
LOOP="false"
QUALITY="high"
SCALE="SHOWALL"
swLiveConnect="true"
PLUGINSPAGE="http://www.macromedia.com/go/flashplayer/">
</EMBED>
< /OBJECT>
< /BODY>
< /HTML>


Products  |  Download  |  Purchase  |  Support  |  Contacts  |  Testimonials  |  News |  

ByteScout, 2003-2008. All other company and product names may be trademarks of their respective companies. Privacy Statement