FLASH AS3全屏类

FLASH AS3全屏类

演示代码:
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中使用方法:
function cl(evt:MouseEvent):void {
 stage.displayState=StageDisplayState.FULL_SCREEN;
}
my_btn.addEventListener(MouseEvent.CLICK,cl);

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值