Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package
- {
- import flash.display.Sprite;
- import flash.events.Event;
- import flash.display.MovieClip;
- import flash.display.Bitmap;
- import flash.display.BitmapData;
- import flash.geom.Matrix;
- import flash.geom.Rectangle;
- public class Main extends Sprite
- {
- public var movieClip:MovieClip;
- public var bitmapData:BitmapData
- public var bitmap:Bitmap;
- public var maxMCheight:Number = 0;
- public var maxMCwidth:Number = 0;
- public function Main():void
- {
- if (stage) init();
- else addEventListener(Event.ADDED_TO_STAGE, init);
- }
- private function init(e:Event = null):void
- {
- removeEventListener(Event.ADDED_TO_STAGE, init);
- addEventListener(Event.ENTER_FRAME, update);
- // for comparison, this is what I want the result to look like
- movieClip = new skeletonDeath();
- movieClip.x = 200;
- movieClip.y = 200;
- addChild(movieClip);
- // and this it the problem child
- bitmap = new Bitmap();
- bitmap.x = 70;
- bitmap.y = 300;
- addChild(bitmap);
- for (var i:uint = 0; i < movieClip.totalFrames; i++)
- {
- var tempBounds:Rectangle = movieClip.getBounds(movieClip);
- if (tempBounds.height > maxMCheight) maxMCheight = tempBounds.height;
- if (tempBounds.width > maxMCwidth) maxMCwidth = tempBounds.width;
- movieClip.nextFrame();
- }
- movieClip.gotoAndPlay(1);
- }
- private function update(e:Event):void
- {
- var bounds:Rectangle = movieClip.getBounds(movieClip);
- bitmapData = new BitmapData(maxMCwidth, maxMCheight, true, 0x0);
- bitmapData.draw(movieClip, new Matrix(1, 0, 0, 1, maxMCwidth - (bounds.x + bounds.width), maxMCheight - (bounds.y + bounds.height)));
- bitmap.bitmapData = bitmapData;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement