+ -
当前位置:首页 → 问答吧 → 请教FLASH在网页里背景自适应的问题

请教FLASH在网页里背景自适应的问题

时间:2010-12-15

来源:互联网

请教FLASH在网页里背景自适应的问题
就像 http://www.ueaction.com/ 一样。背景变换 LOADING也是适应网页的。 不管网页变大变小。里面的MC还是没有变化。如果缩小到一定尺寸MC就消失

作者: darksos   发布时间: 2010-12-15


http://www.google.com.hk/search?q=resize%20flash023&hl=zh-CN&lr=lang_zh-CN&ie=UTF-8&oe=UTF-8&client=aff-cs-gosurf
复制内容到剪贴板
代码:
package{
import flash.display.Bitmap;
    import flash.display.Sprite;
import flash.geom.Matrix;
import flash.display.Loader;
    import flash.events.Event;
    import flash.net.URLRequest;
    /**
    * ...
    * @author FLASH023
    */
    public class Main extends Sprite {
  private var loader:Loader;
  private var bg:Bitmap  ;
        public function Main():void {
   init();   
        }
  private function init():void {
   imgLoader ("image.jpg");
   stage.align = "TL";
   stage.scaleMode = "noScale";
   stage.addEventListener (Event.RESIZE, onResize);
   stage.addEventListener (Event.FULLSCREEN, onResize);
  }
  private function onResize(_evt:Event):void {
   if (bg) {
    bg.width = stage.stageWidth;
    bg.height = stage.stageHeight;
   }
  }
        private function imgLoader(_path:String ):void{
            loader = new Loader;
            loader.contentLoaderInfo .addEventListener (Event.COMPLETE , imageComplete);
            loader.load(new URLRequest (_path));
        }
        private function imageComplete(_evt:Event):void{
            bg  = _evt.target.content as Bitmap;
   onResize(null);
   addChild (bg);
            //-------------------
            loader.contentLoaderInfo .removeEventListener (Event.COMPLETE , imageComplete);
            loader = null;
        }  
    }
}
复制代码如果是AS2:
stage.align = "TL";
   stage.scaleMode = "noScale";
   stage.addEventListener (Event.RESIZE, onResize);
   stage.addEventListener (Event.FULLSCREEN, onResize);
参照以上几行改写

同类型参考帖:
http://share.zcool.com.cn/archiver/?tid-71283.html
http://flash.9ria.com/thread-43626-1-1.html
http://flash.9ria.com/viewthread.php?tid=47626&rpid=423653&ordertype=0&page=1#pid423653
http://space.flash8.net/BBS/thread-381767-1-1.html
http://flash.9ria.com/archiver/tid-43626.html
http://flash.9ria.com/viewthread.php?tid=43626&rpid=408714&ordertype=0&page=1#pid408714
http://bbs.blueidea.com/viewthread.php?action=printable&tid=2969923

作者: flash023   发布时间: 2010-12-15