ActionScript实现把多张图片组合成一张图片

 1 /**
 2  * ComingX.com Business License
 3  * 
 4  * Copyright 2012. All rights reserved.
 5  *
 6  * @Author: Lanjie_Shan
 7  * @Email:shanlanjie#hotmail.com
 8  * @Created date: 2012-6-21
 9  */
10 package
11 {
12     import flash.display.Bitmap;
13     import flash.display.BitmapData;
14     import flash.display.BitmapDataChannel;
15     import flash.display.Sprite;
16     import flash.events.Event;
17     import flash.geom.Point;
18     import flash.geom.Rectangle;
19 
20     [SWF(width=800, height=600, frameRate=24, backgroundColor=0xE2E2E2)]    
21     public class ImageGroupDemo extends Sprite
22     {
23         [Embed(source="aaa.png")]      
24         public var BrownCollector:Class;  //图片大小为100*100
25         public var canvas:BitmapData;
26         public var spritesheet:BitmapData;
27         public var rect:Rectangle;
28         public function ImageGroupDemo()
29         {
30             spritesheet = (new BrownCollector() as Bitmap).bitmapData;
31             canvas = new BitmapData(400,500,true,0xffffff);
32             addChild(new  Bitmap(canvas));
33             rect = new Rectangle(0,0,100,100);
34             for(var j:int = 0; j<5; j++)
35             {
36                 for(var i:int = 0; i<4; i++)
37                 {
38                     canvas.copyPixels(spritesheet,rect,new Point(i*100,j*100) );   
39                 }
40             }
41         }
42     }
43 }

效果图:

posted @ 2012-06-22 12:22  简道云  阅读(545)  评论(0编辑  收藏  举报