maximum size of a sprite in as3?

前端 未结 5 592
栀梦
栀梦 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条回答
  •  -上瘾入骨i
    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

提交回复
热议问题