zoukankan      html  css  js  c++  java
  • [转] MovieClip转Bitmap方法

     1 package {
     2  import flash.display.Bitmap;
     3  import flash.display.BitmapData;
     4  import flash.display.Loader;
     5  import flash.display.LoaderInfo;
     6  import flash.display.MovieClip;
     7  import flash.display.Sprite;
     8  import flash.display.StageAlign;
     9  import flash.events.Event;
    10  import flash.net.URLRequest;
    11  import flash.system.System;
    12  public class test extends Sprite
    13  {
    14   private const FILE_PATH:String = "swf/2.swf";
    15   private const CLASS_NAME:String = "Ball";
    16   
    17   private var loader:Loader;
    18   private var request:URLRequest;
    19   
    20   public function test()
    21   {
    22    loader = new Loader();
    23    request = new URLRequest(FILE_PATH);
    24    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
    25    loader.load(request);
    26    this.stage.align=StageAlign.TOP_LEFT;
    27    
    28   }
    29   private function onComplete (event:Event):void {
    30    var loadedSWFInfo:LoaderInfo = event.target as LoaderInfo;   
    31  
    32    var loadedSWF:MovieClip = loadedSWFInfo.content as MovieClip;
    33    
    34    trace(loadedSWF.framesLoaded);   
    35    loadedSWF.stop();
    36    loadedSWF.x=0;
    37    loadedSWF.y=0;
    38    this.addChild(loadedSWF);
    39    trace(System.totalMemory);
    40    loadedSWF.cacheAsBitmap=true;
    41    //loadedSWF.getRect();
    42    var bitmap:BitmapData=new BitmapData(loadedSWF.width,loadedSWF.height);
    43    
    44    loadedSWF.gotoAndStop(2);
    45    bitmap.draw(loadedSWF);
    46    var bb:Bitmap= new Bitmap(bitmap);
    47    this.addChild(bb);
    48    this.removeChild(loadedSWF);
    49    trace(System.totalMemory);
    50   }  
    51  }
    52 }

     转载自:http://blog.sina.com.cn/s/blog_4c53883d0100a7jq.html

  • 相关阅读:
    C++虚函数表理解
    【转】c++虚函数实现原理
    【转】运输层TCP协议详细介绍
    【转】计算机中浮点数的表示
    ARP跨网段广播
    【转】arm和x86的区别
    面向对象六大原则
    安卓 热修复的原理
    Zygote和System进程的启动过程
    Android内存泄漏
  • 原文地址:https://www.cnblogs.com/shuishenwuyu/p/4138061.html
Copyright © 2011-2022 走看看