FLASH AS3全屏类_foxion - 前端与交互设计、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中使用方法(感谢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

AS3加载XML加载图片 2

先加载XML,然后使用Loader类加载XML里面的文件。
其中先使用数组获取XML里文件信息。然后再使用Loader类加载。

package
{
   import flash.display.Loader;
   import flash.display.Sprite;
   import flash.display.MovieClip;
   import flash.net.URLLoader;
   import flash.net.URLRequest;
   import flash.events.Event;
   import flash.events.MouseEvent;
   import flash.text.TextField;
  
  

   public class getFace extends Sprite
   {
     //xml类
     private var my_xml:XML;
     //URLRequest类
     private var my_URLRequest:URLRequest;
     //URLLoader类
     private var my_URLLoader:URLLoader;
     //加载图片类
     private var my_Loader:Loader;
     //初始化暂存图片信息类
     private var my_pic_Arr:Array = [];
     //加载表情默认位置
     private var _left:uint =0;
     private var _top:uint = 0;
     //初始化TextField
     private var _textField:TextField;
     public function getFace(_xmllist:String)
     {
       my_URLRequest = new URLRequest(_xmllist);
       my_URLLoader = new URLLoader();
       my_URLLoader.load(my_URLRequest)
       my_URLLoader.addEventListener(Event.COMPLETE,xmlLoaded)
     }
     //获取场景TextField实例名称
     public function set txtName(_txt:TextField):void
     {
       _textField = _txt;
     }
     //===加载XML类,将XML信息写进数组中======
     private function xmlLoaded(e:Event):void
     {
       my_xml = new XML(my_URLLoader.data);
       for (var i:uint = 0; i < my_xml.img.length(); i++ )
       {
         var my_Obj:Object = new Object();
         my_Obj.imgsrc = my_xml.img[i].@src;
         my_Obj.swfsrc = my_xml.img[i].@swf;
         my_pic_Arr.push(my_Obj);
       }
       trace(my_pic_Arr[2].imgsrc)
       imgLoaded(my_pic_Arr)
     }
     //=========加载图片============
     private function imgLoaded(arr:Array):void
     {
       for (var i:uint = 0; i < my_pic_Arr.length; i++ )
       {
         var my_Loader:Loader = new Loader();
         my_Loader.load(new URLRequest(my_pic_Arr[i].imgsrc));
         var tmp:MovieClip = new MovieClip();
         tmp.x = _left;
         tmp.y = _top;
         tmp.id = i;
         _left += tmp.width + 48;
         if (_left + tmp.width > 250)
         {
           _left = 0;
           _top += tmp.height + 48;
         }
         tmp.addChild(my_Loader);
         tmp.addEventListener(MouseEvent.CLICK,addTextField)
         addChild(tmp)      
       }
     }
    
     private function addTextField(e:MouseEvent):void
     {
       _textField.htmlText += "<img src='" + my_pic_Arr[e.currentTarget.id].swfsrc +"'>"
       //trace("click it")
     }
    
   }
  
}



郑重声明:资讯 【FLASH AS3全屏类_foxion - 前端与交互设计、AS3_百度空间】由 发布,版权归原作者及其所在单位,其原创性以及文中陈述文字和内容未经(企业库qiyeku.com)证实,请读者仅作参考,并请自行核实相关内容。若本文有侵犯到您的版权, 请你提供相关证明及申请并与我们联系(qiyeku # qq.com)或【在线投诉】,我们审核后将会尽快处理。
—— 相关资讯 ——