Is there an upper bound to the size of a sprite in as3 / flash 10?
I know bitmapData has limitations...
Is there an upper bound to the size of a sprite in as3 / flash 10?
I know bitmapData has limitations...
it seems, that xScale and yScale may not exceed 0x8000 ...
size itself also seems to be bound ... i found a limit 0x6666660 ...
here the code:
package {
import flash.display.*;
public class Main extends Sprite {
public function Main():void {
var size:Number = 1;
var s:Shape = new Shape();
s.graphics.beginFill(0xFF00FF);
s.graphics.drawRect(0, 0, size, size);
var old:Number = 0;
while (s.width > old) {
old = s.scaleX;
s.scaleX *= 1.1;
}
trace(s.width.toString(16));
size = 1;
s.scaleX = 1;
while (true) {
size *= 2;
s.graphics.clear();
s.graphics.drawRect(0, 0, size, size);
if (s.width < 0) break;
}
var min:Number = size / 2;
var max:Number = size;
while (true) {
size = (min + max) / 2;
s.graphics.clear();
s.graphics.drawRect(0, 0, size, size);
if (s.width < 0) max = size;
else
if (max - min < 1) break;
else min = size;
}
trace(s.width.toString(16));
}
}
}
didn't find any documentation about it ... so you may even get other results on your machine ...
I have some experience with Flash 6 and that was the 2880 x 2880 pixel limit with bitmaps.
When creating movieclips there was no problem having this 50000 pixels wide and zooming this e.g. 10x was no problem either.
So I guess you are pretty safe with anything other than the bitmaps which sometimes is a bit of a pain because of the file size restriction.
There are actually a few limitations that I would advice you not to exceed. I'm not 100% sure, but in my tests, you can't BitmapData.draw() any DisplayObject beyond 4079 pixels in width and 4082 in height (actually you can, but they will not be drawn beyond this limits). You can, however, draw BitmapDatas bigger than that.
I've also found that these values appear to be the "safe" boundaries for the bounding box of any DisplayObject. DisplayObjects bigger than that will most definitely be quite buggy... rendering issues in the edges and interactive glitches all around are very common in such scenarios.
Back2dos' post seems very informative, but just watch out if you are caching as a bitmap (DisplayObject.cacheAsBitmap
= true, applying a BitmapFilter
will also cause this), as you will then be limited by flash's bitmap size limit.