与浏览器脚本的交互的方法<一> |
| 作者:佚名 来源:闪吧 作者: les5332295 更新:2007-1-13 20:46:03 错误报告 我要投稿 |
|
1. getURL向浏览器发送信息 格式:getURL(“地址”,“接收窗口”,“方式”) 例子:
建一个test.fla文档,第一帧 建三个button(btu1,btu2,btu3) 建一个Textinput(input1)
AS脚本:
function opensite() { this.getURL("http://www.macromedia.com", "_self"); } var str:String; function passva() { str = this.input1.text; this.getURL("http://localhost/test.asp", "_blank", "GET"); } function increase() { this.getURL("javascript :alert(’Say Hello!’)"); } btu1.addEventListener("click", mx.utils.Delegate.create(this, opensite)); btu2.addEventListener("click", mx.utils.Delegate.create(this, passva)); btu3.addEventListener("click", mx.utils.Delegate.create(this, increase));
在IIS WEB SERVER上建文档test.asp,加入如下语句:
<form name="form1" method="post" action=""> <input type="text" name="textfield" value=<%=Request.QueryString("str")%>> </form>
FLA例程:
点击浏览该文件 1. loadVariables类 getURL只能向脚本发送数据,不可以接收从脚本回传,而loadVariables就可以实现。
例子 ASP脚本 , CODEPAGE="65001"是使脚本支持 Unicode,文档放于 IIS WEB SERVER根目录下:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%> <% restr="Hi,"+Request.Form("str") Response.Write("rebackdata="+restr) %>
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%> <% restr="Hi,"+Request.Form("str") Response.Write("rebackdata="+restr) %>
Flash影片,在场景建立一个MC(mc1_int),内有一个组件Button(btu1)和一个Label(label1). 场景第一帧的AS
function recievedara() { this.loadVariables("http://localhost/pass.asp", "POST"); } _root.mc1_int.btu1.addEventListener("click", mx.utils.Delegate.create(_root.mc1_int, recievedara));
实例 mc1_int的 AS:
onClipEvent (data) { _root.mc1_int.label1.text = rebackdata.toString(); }
实例 mc1_int元件的 AS,变量 str是存储要发送给 ASP脚本的的内容
var str = this.label1.text;
例程
点击浏览该文件
|
|
| 文章录入:skyuu 责任编辑:skyuu |
|
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |