如何使用StageScaleMode.SHOW_ALL获取舞台尺寸?
如果将 stage.scaleMode 设置为 StageScaleMode.SHOW_ALL,则 swf 可能会放大或缩小,并且可能会在顶部/底部或左侧/右侧进行填充。但是,stage.width + height 始终返回 swf 定义的宽度和高度,而 stage.scaleX + Y 始终返回 1。据我了解,不会引发调整大小事件。那么如何获得实际的比例和尺寸呢?
我想要它们解决两个问题:
只有当用户可以看到它时,我才想用某些东西填充顶部/底部或左/右的填充。
我正在将矢量绘制为位图,并希望正确缩放它,这样它就不会看起来锯齿状(或使用 bitmap.smoothing 变得模糊)。当您cacheAsBitmap=true时,Flash似乎可以正确地进行缩放,那么我该如何重新创建它
If you set the stage.scaleMode to StageScaleMode.SHOW_ALL, your swf may be scaled up or down, and may be padded on the top/bottom or left/right. However, stage.width + height always return the width and height as defined by your swf, and stage.scaleX + Y always return 1. As I understand it, resize events are not thrown. So how do I get the actual scale and dimensions?
I want them for two problems:
I want to fill that padding on the top/bottom or left/right with something only if the user can see it.
I am drawing vectors into bitmaps and want to properly scale it so it doesn't look jagged (or fuzzy with bitmap.smoothing). Flash seems to do the scaling correctly when you cacheAsBitmap=true, so how do I recreate this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的情况下,使用 StageScaleMode.NO_SCALE 并自行编码调整大小可能会更容易:
In your case it would probably be easier to use StageScaleMode.NO_SCALE and to code the resizing yourself:
这是我用来在 swf 加载期间获取尺寸并在稍后根据 bjornson 的答案使用它们缩放位图的代码。
This is the code I used to fetch the dimensions during swf load and use them to scale bitmaps later, based on bjornson's answer above.