将Actionscript 2脚本转换为AS3等效项

时间:2011-12-05 23:19:46

标签: flash actionscript-3 actionscript-2 addeventlistener urlrequest

我有以下代码通过AS2中的单独窗口(通过按钮操作)打开文档:

mapSym_btn.onRelease = function() {
getURL ("https://myPortal.html", "_blank")}

有人能告诉我如何在AS3中获得相同的结果吗?我很感激你的帮助。

1 个答案:

答案 0 :(得分:2)

(未经测试的代码)

mapSym_btn.addEventListener(MouseEvent.CLICK, goSomewhere);
function goSomewhere(evt:MouseEvent):void {
   var request:URLRequest = new URLRequest("https://myPortal.html");
   try{        
      navigateToURL(request, "_blank")
   } catch(e:Error){
      trace("Ah snap, there was a problem!");
   }
}