AS3.0中打开网页链接的方法

  AS3打开网页链接的方法与AS2不同了。
AS2:
my_btn.onRelease=function():Void{
getURL("
http://www.123.com","_blank ")
}
而AS3中的方法改变了:
function _getURL(event:MouseEvent):void {
   var _Newurl:URLRequest=new URLRequest("
http://www.123.com ");
   var _fangshi:String="_blank";
   navigateToURL(_Newurl,_fangshi);
}
my_btn.addEventListener(MouseEvent.CLICK,_getURL);

如果是类:

package
{
   import flash.display.Sprite;
   import flash.events.MouseEvent;
   import flash.net.*;
 
   public class main extends Sprite
   {
     private var my_ball:ball1;
     private var my_url:URLRequest;
     public function main()
     {
       my_ball = new ball1();
       my_ball.x = 150;
       my_ball.y = 200
       addChild(my_ball)
       my_ball.addEventListener(MouseEvent.CLICK,getURLnew)
     }
   
     private function getURLnew(e:MouseEvent):void
     {
       my_url = new URLRequest("
http://www.123.com");
       var _fangshi:String = "_blank";
       navigateToURL(my_url ,_fangshi);
     }
   
   }
 
}

你可能感兴趣的:(ActionScript)