Returns an array of BitmapData based on this BitmapData's texture.
This function is used to "slice" a spritesheet, tileset, or spritemap into several different frames. All BitmapData's produced by this method are linked to this BitmapData's texture for performance.
The optional frameCount parameter will limit the number of frames generated, in case you have empty frames you don't care about due to the width / height of this BitmapData. If your frames are also separated by space or have an additional margin for each frame, you can specify this with the spacing or margin parameter (in pixel).
Source
List<BitmapData> sliceIntoFrames(num frameWidth, num frameHeight, {int frameCount: null, num frameSpacing: 0, num frameMargin: 0}) { var cols = (width - frameMargin + frameSpacing) ~/ (frameWidth + frameSpacing); var rows = (height - frameMargin + frameSpacing) ~/ (frameHeight + frameSpacing); var frames = new List<BitmapData>(); frameCount = (frameCount == null) ? rows * cols : min(frameCount, rows * cols); for (var f = 0; f < frameCount; f++) { var x = f % cols; var y = f ~/ cols; var frameLeft = frameMargin + x * (frameWidth + frameSpacing); var frameTop = frameMargin + y * (frameHeight + frameSpacing); var rectangle = new Rectangle<num>(frameLeft, frameTop, frameWidth, frameHeight); var bitmapData = new BitmapData.fromBitmapData(this, rectangle); frames.add(bitmapData); } return frames; }