北京雷洋案律师:关于Flash的问题,需要高手解答
来源:百度文库 编辑:高考问答 时间:2024/05/06 00:33:08
换个方式问:我知道HTML无法处理Flash里面的事件,但我想知道Flash能否处理HTML里的事件或过程。比如我的HTML里有个function example(),我在Flash里能否直接调用这个过程,还是必须用getURL("javascript:example")呢?
50分不成敬意,望高手指教,谢谢!
FLASH 和 JS 是可以交互的。
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>
这个是转贴,忘了来自什么地方了。