使用 ActionScript 3.0 调整窗口大小

发布于 2024-07-14 21:34:54 字数 301 浏览 5 评论 0原文

有没有办法使用 Actionscript 或其他方法调整整个 Flash 项目的大小?

我创建了一个 1024x768 Flash CS3 应用程序,但在仔细检查规格后,我现在意识到它必须是 800x600。 我不想手动缩小所有内容,而是想调整窗口大小,就像有人拖动外边缘一样。 或者添加一个允许在 1024x768 和 800x600 之间切换的按钮。 这可能吗?

我的意思是这样的:

stage.stageWidth = 800;
stage.stageHeight = 600;

Is there any way to resize an entire Flash project using Actionscript or some other method?

I have created a 1024x768 Flash CS3 application, but upon closer inspection of the specifications, I now realise it has to be 800x600. Instead of manually making everything smaller, I'd like to resize the window as if someone were dragging the outside edge. Or perhaps add a button that allows switching between 1024x768 and 800x600. Is this possible?

I mean something like this:

stage.stageWidth = 800;
stage.stageHeight = 600;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

舂唻埖巳落 2024-07-21 21:34:54

是的,stageWidth 和 stageHeight 是只读的,尽管有文档。 但是,如果 SWF 嵌入到网页中,则更改其元素宽度和高度将更改舞台大小,并且 scaleMode 将确定如何处理。 我的 Enjoy3D 网站 上的所有 SWF 都会在窗口大小调整时执行此操作...

Yes stageWidth and stageHeight are readonly, despite the docs. But if the SWF is embedded in a web page, then changing its element width and height will change the stage size and scaleMode will determine how that is handled. All the SWFs at my Enjoy3D web site do this on window resize...

成熟的代价 2024-07-21 21:34:54

如果您愿意,您只需编辑 SWF 的 HTML 包装器并判断新尺寸(我担心)和光栅化媒体是否会在缩小时出现像素化。 最好缩小所有内容,即使您不想这样做。

如果您确实需要在 Flash 中执行此操作,请使用 flash.external 包的ExternalInterface 类来调用 HTML 中的 JavaScript 函数。 确保您的 swf 位于 div 内并设置为 div 高度和宽度的 100%。 现在,您只需通过 JavaScript 通过 Actionscript 更改 div 的大小。

确保您已按照您想要的方式设置 stage.scaleMode。

干杯

If you wanted you could merely edit the HTML wrapper for your SWF and tell if the new dimensions, though I fear and rasterized media will be pixelated even when shrinking. It is best to shrink everything, even though you don't want to.

If you just really need to do it in flash use the ExternalInterface class of the flash.external package to make a call to a JavaScript function in your HTML. Make sure your swf is inside a div and set to 100% of the div's height and width. Now you merely change the size of the div via JavaScript via Actionscript.

Make sure that you have stage.scaleMode set the way you want it.

Cheers

仅冇旳回忆 2024-07-21 21:34:54

您无法从 Actionscript 更改舞台宽度和高度,这些属性是只读的。

在编译 swf 之前,您不能将舞台属性的大小(我假设您在这里使用 Flash)设置为 800 x 600 吗?

You can't change the stage width and height from Actionscript, those properties are read-only.

Couldn't you just set the size of the stage properties (I assume you're using Flash here) to 800 by 600 before you compile your swf?

虫児飞 2024-07-21 21:34:54
  1. 您可以在 xxx-app.xml 文件中设置宽度和高度属性
  2. 如果您想动态执行此操作,可以使用 FlexGlobals.topLevelApplication.width 和 height 属性或已弃用的 Application.application.width 和 height 属性
  3. 或者如果您有一个纯 ActionScript 项目,无法执行 FlexGlobals 或 Application,您可以从主 ActionScript 文件(Sprite)执行以下操作(请注意,在执行此操作之前必须初始化阶段)

    宽度=宽度; 
      高度=高度; 
      stage.stageWidth = 宽度; 
      stage.stageHeight = 高度; 
      stage.nativeWindow.width = WIDTH; 
      stage.nativeWindow.height = 高度; 
      
  1. You could set the width and height properties in your xxx-app.xml file
  2. If you want to do it dynamically, you could use FlexGlobals.topLevelApplication.width and height properties or the deprecated Application.application.width and height properties
  3. Or if you have a pure ActionScript project, whereby you cannot do FlexGlobals or Application, you could from your main actionscript file (Sprite) execute the following (note that stage must be initialised before doing this)

    width = WIDTH;
    height = HEIGHT;
    stage.stageWidth = WIDTH;
    stage.stageHeight = HEIGHT;
    stage.nativeWindow.width = WIDTH;
    stage.nativeWindow.height = HEIGHT;
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文