maximum size of a sprite in as3?

前端 未结 5 591
栀梦
栀梦 2021-01-07 13:28

Is there an upper bound to the size of a sprite in as3 / flash 10?

I know bitmapData has limitations...

相关标签:
5条回答
  • 2021-01-07 13:48

    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.

    0 讨论(0)
  • 2021-01-07 13:54

    In AIR 1.5 and Flash Player 10, the maximum size for a bitmap image is 8,191 pixels in width or height, and the total number of pixels cannot exceed 16,777,215 pixels. (So, if a bitmap image is 8,191 pixels wide, it can only be 2,048 pixels high.) In Flash Player 9 and earlier, the limitation is is 2880 pixels in height and 2,880 pixels in width.

    Taken from http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html

    0 讨论(0)
  • 2021-01-07 13:54

    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.

    0 讨论(0)
  • 2021-01-07 14:06

    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.

    0 讨论(0)
  • 2021-01-07 14:07

    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 ...

    greetz

    back2dos

    0 讨论(0)
提交回复
热议问题