View difference between Paste ID: KyU5FPeJ and v7yxptkz
SHOW: | | - or go back to the newest paste.
1
package 
2
{
3
	import flash.display.Sprite;
4
	import flash.events.Event;
5
	import flash.display.MovieClip;
6
	import flash.display.Bitmap;
7
	import flash.display.BitmapData;
8
	import flash.geom.Matrix;
9
	import flash.geom.Rectangle;
10
	
11
	public class Main extends Sprite 
12
	{
13
		public var movieClip:MovieClip;
14
		public var bitmapData:BitmapData
15
		public var bitmap:Bitmap;
16
		public var maxMCheight:Number = 0;
17
		public var maxMCwidth:Number = 0;
18
		
19
		public function Main():void 
20
		{
21
			if (stage) init();
22
			else addEventListener(Event.ADDED_TO_STAGE, init);
23
		}
24
		
25
		private function init(e:Event = null):void 
26
		{
27
			removeEventListener(Event.ADDED_TO_STAGE, init);
28
			addEventListener(Event.ENTER_FRAME, update);
29-
				
29+
30-
				
30+
31
			// for comparison, this is what I want the result to look like
32
			movieClip = new skeletonDeath();
33
			movieClip.x = 200;
34
			movieClip.y = 200;
35
			addChild(movieClip); 
36-
				
36+
37
			// and this it the problem child
38
			bitmap = new Bitmap();
39
			bitmap.x = 70;
40
			bitmap.y = 300;
41
			addChild(bitmap);
42-
				
42+
43
			for (var i:uint = 0; i < movieClip.totalFrames; i++)
44
			{
45
				var tempBounds:Rectangle = movieClip.getBounds(movieClip);
46
				if (tempBounds.height > maxMCheight) maxMCheight = tempBounds.height;
47
				if (tempBounds.width > maxMCwidth) maxMCwidth = tempBounds.width;
48
				movieClip.nextFrame();
49
			}
50-
				
50+
51
			movieClip.gotoAndPlay(1);
52
		}
53
		
54
		private function update(e:Event):void
55
		{
56
			var bounds:Rectangle = movieClip.getBounds(movieClip);
57
			bitmapData = new BitmapData(maxMCwidth, maxMCheight, true, 0x0);
58-
			bitmapData.draw(movieClip, new Matrix(1,0,0,1,-bounds.x, -bounds.y+bounds.height));
58+
			bitmapData.draw(movieClip, new Matrix(1, 0, 0, 1, maxMCwidth - (bounds.x + bounds.width), maxMCheight - (bounds.y + bounds.height)));
59
			bitmap.bitmapData = bitmapData;
60
		}
61
		
62
	}
63
	
64
}