SWF Scout |
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" 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"> <BODY> <EMBED |
|
|
||