缩小以适应分辨率,但在 Flash CS4 中不放大

发布于 2024-08-05 13:51:36 字数 494 浏览 2 评论 0原文

我的女朋友是一名平面设计师,目前在一个网站上工作。她不懂任何 HTML 或 CSS,只熟悉 Flash,因此她使用 Flash 构建整个网站。应该指出的是,我是开发人员,对 HTML、CSS 或 Flash 的经验几乎为零。

工作进展顺利,但在我帮助她部署网站(通过“文件”->“发布”)后,我们遇到了一些问题。她制作了 1000x750 像素的 .swf 影片。在我的 24 英寸显示器上以 1920x1200 的分辨率检查生成的网站后,一切看起来确实像素化(电影使用图像,而不是矢量图形)。没问题!我想我们应该在 Flash 的发布选项中禁用缩放功能,这样就可以了。

然而,禁用缩放显然引入了一个新问题,即现在无法在运行低分辨率(<=1024x768)的计算机上正确观看电影,

我想我们正在寻找的行为只是缩小 电影以适应观看计算机的分辨率/浏览器窗口,但不放大 Flash (CS4) 似乎没有在其发布选项中包含此选项,是否有任何简单的方法可以启用这种行为?

My girlfriend is a graphic designer who is currently working on a website. She doesn't know any HTML or CSS and is only familiar with Flash, so she's building the entire website in Flash. It should be noted that I am developer and have close to 0 experience with HTML, CSS or Flash either.

Work is progressing nicely, but after I helped her deploy the site (through File->Publish), we ran into some issues. She built the .swf movie at 1000x750 pixels. After inspection of the resulting website at my 24" monitor at 1920x1200, things looked really pixelated (the movie uses images, not vector graphics). No problem! I figured we should just disable scaling in Flash's publish options and we'd be good.

However, disabling scaling apparently introduced the new problem that the movie could now no longer be properly viewed at computers running low (<=1024x768) resolutions.

I guess the behavior we're looking for is to only scale down the movie to fit the viewing computer's resolution/browser window, but not scale up. Flash (CS4) does not seem to include this as an option in its publish options though. Are there any simple methods to enable such behavior?

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

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

发布评论

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

评论(1

木槿暧夏七纪年 2024-08-12 13:51:36

对于您所描述的内容,没有内置选项,但可以通过 Flash 内部或 JavaScript 端的脚本轻松实现。我将在答案的末尾添加一个代码片段,它应该可以让您开始运行。

不过,首先让我建议您可能应该做什么。想象一下当用户(无论显示器大小)没有全屏浏览器时会发生什么。如果您按照您所描述的方式实现,他们会看到您的网站尺寸任意小,具体取决于其浏览器的大小,并且很可能会看到一些小到难以辨认和/或无法使用的内容。

现在当然,您可以通过进一步实现最小尺寸来解决这个问题,低于该尺寸时 Flash 会停止缩放,但随后您会开始对用户希望如何查看您的网站进行大量事后猜测。相反,您应该问,拥有小显示器(或小浏览器窗口)的用户期望网站做什么?答案是,以全尺寸显示网站并添加滚动条。为了我的钱,这就是你的网站应该做的。

因此,在 HTML(或 Flash 的 HTML 导出设置)中将 SWF 嵌入到 1000x750 容器中。这将使 SWF 无法为任何人缩放 - 在您的显示器上,您将看到未缩放的网站在窗口内居中(或左上角对齐或其他),而在较小的显示器上,您将看到整个网站未缩放,并带有浏览器滚动条。

归根结底,您必须认识到,尽管 Flash 内容本质上是可缩放的,但大多数网站都是由文本和图像组成的,而事实并非如此。即使您可以在运行时缩小规模,但这通常不是用户所期望的,并且通常不会使网站看起来很好。


现在,正如所承诺的,这里有一段 Flash AS3 代码,它应该可以让您有足够的优势来进行任何您喜欢的缩放操作。如果您已将 Flash 发布到占据整个浏览器窗口的容器中,并将缩放模式设置为“无缩放”,这应该会给您带来所需的效果。

// perform initial size check
checkStageSize();

// register to re-check when stage size changes
stage.addEventListener( Event.RESIZE, onResize, false, 0, true );
function onResize( e:Event ) {
    checkStageSize();
}

// do the scaling here
function checkStageSize():void {
    var wid:Number = stage.stageWidth;
    var hi:Number = stage.stageHeight;
    var needToScaleDown:Boolean = (wid < 550); // or some other test
    if ( needToScaleDown ) {
        var scale:Number = wid/550;
        someContent.scaleX = someContent.scaleY = scale;
    } else {
        someContent.scaleX = someContent.scaleY = 1;
    }
}

假设“someContent”是指包含要缩放的所有内容的容器,其注册点位于舞台的原点(左上角)。没有简单的方法来自动缩放整个影片,因此您需要将内容放置在容器影片剪辑中并对其进行缩放。

请随意将上面的代码片段放在舞台上的框架动作中,更改“someContent”以引用您可以缩放的容器,然后使用它。但我真的认为您最终会决定仅显示未缩放的网站更有用。

There's no built-in option for what you're describing, but it's easily achieved with scripting, either from within Flash or on the JavaScript side. I'll put a code snippet at the end of the answer that ought to get you off and running.

First, however, let me suggest what you probably ought to do instead. Think of what happens when a user comes along who (regardless of monitor size) doesn't have their browser fullscreen. If you implement as you describe, they'll see your site at an arbitrarily small size, depending on how their browser is sized, and quite possibly see something small enough to be illegible and/or unusable.

Now sure, you could deal with that by further implementing a minimum size below which the Flash stops scaling, but then you're starting to do a lot of second-guessing about how users will want to see your site. Instead, it behooves you to ask, what would a user with a small monitor (or a small browser window) expect the site to do? And the answer to that is, show the site full-size and add scrollbars. And for my money, that's what your site should do.

So in your HTML (or in Flash's HTML export settings) embed your SWF into a 1000x750 container. This will keep the SWF from scaling for anyone - on your monitor you'll see the unscaled site centered (or top-left aligned or whatever) within the window, and on smaller monitors you'll see the whole site unscaled, with browser scrollbars.

At the end of the day, you have to realize that even though Flash content scales inherently, most web sites are made up of text and images, which don't. Even though you can scale down at runtime, it's usually not what the user expects and it usually doesn't make the site look good.


Now as promised, here's a snippet of Flash AS3 code that ought to give you enough head start to do anything you like with scaling. This ought to give you the desired effect, if you've published your Flash into a container that takes up the entire browser window, with the scalemode set to "no scale".

// perform initial size check
checkStageSize();

// register to re-check when stage size changes
stage.addEventListener( Event.RESIZE, onResize, false, 0, true );
function onResize( e:Event ) {
    checkStageSize();
}

// do the scaling here
function checkStageSize():void {
    var wid:Number = stage.stageWidth;
    var hi:Number = stage.stageHeight;
    var needToScaleDown:Boolean = (wid < 550); // or some other test
    if ( needToScaleDown ) {
        var scale:Number = wid/550;
        someContent.scaleX = someContent.scaleY = scale;
    } else {
        someContent.scaleX = someContent.scaleY = 1;
    }
}

This supposes that "someContent" refers to a container holding everything you want to scale, with its registration point at the stage's origin (upper-left corner). There's no easy way to automatically scale the whole movie, so you'll want to place your content in a container movie clip and scale that instead.

Feel free to put the snippet above in a frame action on the stage, change "someContent" to refer to a container you can scale, and play around with it. But I really think you'll wind up deciding that it's more usable to just show the site unscaled.

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