|
import fl.controls.Button;
import flash.net.URLRequest;
import flash.net.navigateToURL;
var btn1:Button= new Button();
addChild(btn1);
btn1.addEventListener(MouseEvent.CLICK, this.onClickBtn4);
function onClickBtn1(e:MouseEvent) {
//用String方式赋值
var m_urlList:String=new String("http://www.towncool.com");
var m_request:URLRequest = new URLRequest(m_urlList);
navigateToURL(m_request,"_blank");
}
//用textField文本方式赋值
function onClickBtn2(e:MouseEvent) {
var m_urlList:TextField=new TextField();
m_urlList.text="http://www.towncool.com";
var m_request:URLRequest = new URLRequest(m_urlList.text);
navigateToURL(m_request,"_blank");
}
function onClickBtn3(e:MouseEvent) {
//用数组方式赋值,适用于调用按钮执行多个链接
var m_urlList:Array=["http://www.towncool.com","http://www.towncool.net","http://www.baidu.com"];
var m_request:URLRequest = new URLRequest(m_urlList[2]);
navigateToURL(m_request,"_blank");
}
function onClickBtn4(e:MouseEvent) {
//直接赋值
var m_request:URLRequest = new URLRequest("http://www.towncool.com");
navigateToURL(m_request,"_blank");
}
本文由胡金金个人网站整理发布,转载请注明地址:http://www.hujinjin.com/info/101.html