FLASH AS3全屏类 [ 网站地图 ]

发表于:2009-11-13 浏览:41 作者: 来源:互联网

关键字:FLASH

描述: 代码: package {  import flash.display.MovieClip;  import flash.display.Sprite;  import flash.events.MouseEvent;  import f

代码:
package {
  import flash.display.MovieClip;
  import flash.display.Sprite;
  import flash.events.MouseEvent;
  import flash.text.TextField;
  import flash.text.TextFieldAutoSize;
  public class fullbotton extends MovieClip {
    public function fullbotton(b_width:int,b_height:int,f_size:int) {
      var _Rect:Sprite = new Sprite();
      _Rect.graphics.beginFill(0xff0000,1);
      _Rect.graphics.drawRect(0, 0, b_width,b_height);
      _Rect.graphics.endFill();
      addChild(_Rect);
      _Rect.buttonMode=true;
      var t:TextField = new TextField();
      t.htmlText="<FONT SIZE=’"+f_size+"’ color=’#ffff00’ ><b>点击此处切换观看模式(全屏/普通)</b></font>";
      t.autoSize=TextFieldAutoSize.LEFT;
      t.x=30;
      t.y=2;
      _Rect.addChild(t);
      var _Rect1:Sprite = new Sprite();
      _Rect1.graphics.beginFill(0x000000,0);
      _Rect1.graphics.drawRect(0, 0, b_width,b_height);
      _Rect1.graphics.endFill();
      _Rect.addChild(_Rect1);
      _Rect.addEventListener(MouseEvent.CLICK, clickHandler);
    }
    private function clickHandler(event:MouseEvent):void {
      switch (stage.displayState) {
        case "normal" :
          stage.displayState="fullScreen";
          break;
        case "fullScreen" :
        default :
          stage.displayState="normal";
          break;
      } 
    }
  }
}
使用:
var my_btn:fullbotton=new fullbotton(100,50,12);
addChild(my_btn);

在HTML中使用方法(感谢KAKA):
function cl(evt:MouseEvent):void {
  stage.displayState=StageDisplayState.FULL_SCREEN;
}
my_btn.addEventListener(MouseEvent.CLICK,cl);

然后HTML标签中修改一下:
要在标签中加入allowFullScreen="true"

演示:
http://www.taoshaw.com/taoshaw/study/as3fullscreen/method2.html

站长资讯网 做中国最丰富的资讯网站 沪ICP备05004089号