FSCommand 用法详解,FSCommand 用法详解
【 tulaoshi.com - Flash 】
1、FS Command介绍FS Command命令是Flash系统用来支持其他应用程序互相传达命令的工具,有在Flash播放器和网页两方面用途。先看看它的基本用法:
FS Command函数设定有''Command''和''Arguments''两项,在Standalone player播放时适用于以下语句:
  Command Arguments FS Command 
Fullscreen true or false 控制是否全屏 
Allowscale true or false 右键显示菜单 
Exec 应用程序路径 打开应用程序 
Quit 不填 关闭动画
  注意:与在网页中,全屏播放的方法是不同的!
  2、FS Command页面初级用法 
  在网页应用上,FS Command有两大功能
  (1)能使Flash向脚本语言发送命令。可以是调用脚本语言中的一段函数或传递变量给脚本语言等。
  (2)能使脚本语言(js,vbs)向Flash发送命令。可以是给Flash中定义变量或是直接控制Flash动画的时间线上的跳转或给Flash中定义实体的属性等。
  为了使大家有一个感性的认识,先来看这个程序:
  看到了么?它是这样实现的:
  (1)用Flash作一个简单的按钮,将按钮的Action设为:
On(Release)
FSCommand("alert","Hello,This is FS Command speaking")
End On
  (2)将按钮输出为swf,用Dreamweaver插入网页,并起ID名为"button"
  (3)在网页<head与</head之间加入:
<script language=javascript
function button_DoFSCommand(command,args)
{if(command == "alert"){
alert("Now look at this:"+args);}
}
</script
<SCRIPT LANGUAGE=VBScript
Sub button_FSCommand(ByVal command, ByVal args)
call button_DoFSCommand(command, args)
end sub
</SCRIPT
   下面对(3)点的语法做一些解释:"function ID_DoFSCommand(command,args)"是引用FS Command的一个固定格式,ID就是swf插入网页后起的ID名字。"if(command="")句的后面要填的就是FlashAction中command栏里填写的内容,"args"是个变量,上例中args代表的就是Argument里的内容。"alert"是"JS"函数,作用是输出信息。看到JS语句后面的一段VBS代码了么?这段代码可是非常重要噢,如果你的浏览器是IE的话,这段代码是必不可少的。
  3、FS Command之Flash Methods
  Flash Methods指能运行在脚本中并能于Flash沟通的一组特定函数。
  在IE中Flash Methods的格式为:ID.FlashMethods
  我们还是用学习例子的方法来了解Flash Methods的功能和用法吧:
  请点击按钮!看到效果了么?它是这样实现的:
  (1)在Flash中画一个文本框,定义其实体名为get,并设置文本的属性为Multiline(允许换行),Word wrap(边界换行)。
  (2)制作按钮“提交”和“清除”,分别设置action为:
On(Release)
FSCommand("post","")
End On
On(Release)
FSCommand("clear","")
End On
  (3)用Dreamweaver将导出的swf插入网页,起ID名为buttonn。
  (4)网页代码中加入:
<script language=javascript
function buttonn_DoFSCommand(command,args)
{if(command == "post")
buttonn.SetVariable("_root.get","哈哈!神奇吧?这是JavaScript说的话!~0~")
else if(command == "clear")
buttonn.SetVariable("_root.get","")
}
</script 
<SCRIPT LANGUAGE=VBScript
Sub buttonn_FSCommand(ByVal command, ByVal args)
call buttonn_DoFSCommand(command, args)
end sub
</SCRIPT
  4、Flash Methods函数集
   看了上面的例子,你一定对Flash Methods有所了解了吧!下面我来介绍一下Flash Methods的全部函数: 
Flash Method函数 函数解释 
Play() 播放动画 
StopPlay() 停止动画 
IsPlaying() 动画是否正在播放(true,false) 
GotoFrame(frame_number) 跳转到某帧(frame_number+1) 
TotalFrames() 获取动画总帧数 
CurrentFrame() 回传当前动画所在帧数-1 
Rewind() 使动画返回第一帧 
SetZoomRect(left,top,right,buttom) 放大指定区域 
Zoom(percent) 改变动画大小 
Pan(x_position,y_position,unit) 使动画在x,y方向上平移 
PercentLoaded() 返回动画被载入的百分比(0-100) 
LoadMovie(level_number,path) 加载动画 
TGotoFrame(movie_clip,frame_number) movie_clip跳转到指定帧数 
TGotoLabel(mu
                        
来源:http://www.tulaoshi.com/n/20160129/1487671.html
看过《FSCommand 用法详解》的人还看了以下文章 更多>>