AS3打开网页

 package
{
/**
 * @author zoe
 *
 */

import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.net.navigateToURL;

public class Main extends Sprite
{
    
    public function Main()
    {
       var _rectA:Sprite  = new Sprite();
       var rand:uint = Math.random()*0xFFFFFF;
       var posX:Number = stage.stageWidth*Math.random();
       var posY:Number = stage.stageHeight*Math.random();      
       
       _rectA.graphics.beginFill(rand,Math.random());
       _rectA.graphics.drawRect(posX,posY,50,80);
       _rectA.graphics.endFill();
       addChild(_rectA);
       
       _rectA.addEventListener(MouseEvent.CLICK,rectAClickHandler);
    }
    
    private function rectAClickHandler(event:MouseEvent):void
    {
        // TODO Auto-generated method stub
        var url:URLRequest = new URLRequest("http://sxd.xd.com/");
        navigateToURL(url);
    }
}
}
posted on 2012-11-05 08:48  橙小风  阅读(1339)  评论(0编辑  收藏  举报