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