2016-10-13 00:16:48 点击量:6 标签: 收藏本文
Flash AS2的写法示例:
点击按钮链接外部网页:on(release){getURL("外部网页网址","打开网页的方式如_blank");}
点击按钮链接内部网页:on(release){getURL("内部网页的名称和后缀", "打开网页的方式如_blank" );}
点击按链连接下载文件:on(release){getURL("下载文件的名称和后缀");}
内部链接/下载:要打开的内部网页/下载文件都必须和按钮的文件放在同一个文件夹中,
如果内网页链接有子目录-针对网页:on(release){getURL("子目录文件夹名称/内部网页的名称和后缀", "打开网页的方式如_blank" );}
如果内网页链接有子目录-针对下载文件:on(release){getURL("子目录文件夹名称/下载文件的名称和后缀");}
点击按钮链接电子邮件:on(release){getURL("zz#wuroom.com");}
_self 指定当前窗口中的当前框架。
_blank 指定一个新窗口。
_parent 指定当前框架的父级。
_top 指定当前窗口中的顶级框架。
- geturl(“http://www.CuPlayer.com"," _blank”)
- on(release){getURL("http://www.CuPlayer.com","_blank");}
- on (release){
- getURL("http://www.CuPlayer.com", "_blank");
- }
Flash AS3的写法示例:
flash as3 链接代码不能写在元件上面,只能写在帧上面
添加单个链接的方法:
- function GoToURL(event:MouseEvent){
- var url=new URLRequest("http://www.cuplayer.com")
- navigateToURL(url,"_self")
- }
- url_btn.addEventListener(MouseEvent.MOUSE_DOWN,GoToURL)
多个的方法:
- url_btn.addEventListener(MouseEvent.MOUSE_DOWN,GoToURL1)
- ur2_btn.addEventListener(MouseEvent.MOUSE_DOWN,GoToURL2)
- ur3_btn.addEventListener(MouseEvent.MOUSE_DOWN,GoToURL3)
- function GoToURL1(event:MouseEvent){
- var url=new URLRequest("http://www.cuplayer.com/index.html")
- navigateToURL(url)
- }
- function GoToURL2(event:MouseEvent){
- var url=new URLRequest("http://www.cuplayer.com/index.html")
- navigateToURL(ur2)
- }
- function GoToURL3(event:MouseEvent){
- var url=new URLRequest("http://www.cuplayer.com/index.html")
- navigateToURL(ur3)
- }
按钮的名字叫url_btn、ur2_btn和ur3_tn,
- function GoToURL(event:MouseEvent){
- navigateToURL(new URLRequest("http://www.cuplayer.com"),"_self");
- }
- url_btn1.addEventListener(MouseEvent.MOUSE_DOWN,GoToURL)
- function GoToURL1(event:MouseEvent){
- var url=new URLRequest("zz/index.html")
- navigateToURL(url)
- }
- url_btn.addEventListener(MouseEvent.MOUSE_DOWN,GoToURL1)
html 页中的 JavaScript 函数:
- function GetSwfUrl()
- {
- var pic = "http://www.cuplayer.com/test.swf";
- document.my_swf_Id.SetVariable("SiteName", pic);
- }
FLASH中任何一侦上写:
import flash.external.ExternalInterface;//导入 ExternalInterface 类
ExternalInterface.call("GetSwfUrl()");
在 Flash 中与 JS 的通信可以用传统的 getURL,Flash8 以后,可以用 ExternalInterface 。ExternalInterface 在功能上与 fscommand()、CallFrame() 和 CallLabel() 方法相似,但它更灵活、更通用。推荐对 JavaScript 和 ActionScript 之间的通讯使用 ExternalInterface 。
getURL调用JS:
getURL("javascript:GetSwfUrl()");
ExternalInterface调用JS:
import flash.external.ExternalInterface;//导入 ExternalInterface 类
ExternalInterface.call("GetSwfUrl()");
注意:如果要使用 ExternalInterface,当前帧必需要有 import flash.external.ExternalInterface; 或者 import flash.external.*;
我们是一家提供综合软件外包与弱电工程服务的技术公司。
业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。
公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室