【ADOBE COUNSULT】Flex 和 ScaleMode

导读:
  Flex’s underlying Flash Player has various ScaleModes that dictate how the screen should respond when the Flash ‘window’ is resized. By default, Flex apps use the NO_SCALE, which means that the screen area gets larger or smaller and can clip off the right and bottom of the screen. Flex will put up scrollbars in that case. It is the most common way applications respond to changes in screen size.


Flex的目标flash播放器有各种各样的伸缩模式,这些伸缩模式告知播放器应该如何重绘flash窗口的大小。缺省情况下flex应用程序使用NO-SCALE无伸缩模式。这意味着flex应用程序可以通过右边和底部的伸缩栏来调整大小,如果flash窗口超出了屏幕,那么flex通过装置滚动栏响应窗口大小的变化。
  Every once in a while, someone wants to use one of the other ScaleModes which essentially magnify or reduce what you see in the Flash ‘window’. There is a trick to getting this to work correctly in Flex.


总会有一些时候,有人想要使用其他的模式来从本质上改变用户所见的的窗口,这里有个很巧妙的方法在FLEX来实现
  The problem is that the magnification is based on the ‘default’ size of the application. For Flex, the default size is based on the width and height attributes of the application tag. If none are specified, or percentages are used, the default is 500375. If your applications visuals are different from that size, the magnification will look funny as the Flash Player will be trying to resize the upper 500376 of your application into the current window size.


问题在于在应用程序标准大小下来实现放大,对于FLEX,应用程序的标准大小基于application标签的宽和高属性,如果没有规定宽和高,或者使用的是百分数,那么应用程序的大小对设置为500375,如果你的应用程序和那大小不一样,那么magnification对象和flash播放器一样方式将应用程序的目前窗口大小重新设置为500376
  However, if you specify a width/height that just bounds your visuals, the HTML template generated by FlexBuilder will not allow resizing. What you have to do is choose the correct size for your application, and customize the HTML template. Here’s the recipe:
  1) Create your app with the default scale mode.
  2) Figure out how big the app is. In the example, I placed a label at 600,600, but it extends beyond that. One way is to just guess at numbers and see when there isn’t scrollbars or too much excess space. Otherwise, use the debugger or trace out positions and sizes on creationComplete.


3) Set the application’s width/height tags to those exact dimensions
  4) Open the html-templates folder. Right-click the index.template Choose: Open with -> text editor


但是,如果你将应用程序的宽高设置为目标视觉效果,flexbuilder产生的html模板将不允许重置大小。要做的就是为应用程序设置合适大小,然后重新定制HTML模板,下面是具体步骤:


1.使用标准模式创建应用程序


2.想象一下应用程序有多大,在这个例子里面我们设置一个600*600的标签,实际超过这个值.可以简单地猜测一个值,然后将其约束在不出现滚动条的情况下,或者使用调试G追踪creationComplete事件


3.将应用程序的宽的和高设置为精确值


4.打开应用程序的html模板,你将看到下面的部分
  You’ll see this:
  } else if (hasRequestedVersion) { // if we’ve detected an acceptable version
  // embed the Flash Content SWF when all tests are passed
  AC_FL_RunContent(
  “src”, “${swf}”,
  “width”, “${width}”,
  “height”, “${height}”,
  Change the width/height tags back to use %:
  } else if (hasRequestedVersion) { // if we’ve detected an acceptable version
  // embed the Flash Content SWF when all tests are passed
  AC_FL_RunContent(
  “src”, “${swf}”,
  “width”, “100%”,
  “height”, “100%”,There are also other ${width} and ${height| tags for non-scripting browser that you can change as well.
  5) Clean re-build


按照上面的提示修改模板,然后清除并进行重新编译
  That should do it. As long as the application fully covers the size you specified, you should see the correct scale effect as you resize the window.

本文转自
http://blogs.adobe.com/aharui/2008/01/flex_and_scalemodes.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值