flex:调整 SWFLoader 大小和位置时出现问题
我有几个 SWFLoader 的复杂问题。
我有一个使用 SWFLoader 加载 swf 的应用程序。加载的 swf 会加载另一个 swf(只是编译后的 fla)。我在加载的 swf 中添加了所有调整大小和位置逻辑,并且它在事件调整大小上运行良好,但是当我尝试在 swfs applicationComplete 中运行相同的代码时,它失败了。如果我将 swf 作为独立运行,那么启动时的相同代码效果很好,但由于某种原因,当我将其加载到应用程序中时,比例会有所不同。
我只是将其宽度和高度设置为浏览器大小,因此除了比例之外的所有内容都是相同的!
这是我作为独立加载的 swf 的跟踪: swf加载器:1435 742 FlexLoader:1319.1 742 1.0305555555555554 1.0305555555555554
,这是在我的应用程序中加载时来自同一个加载的swf: swf加载器:1435 742 FlexLoader: 1159.55 742 0.9053196681307955 0.9053196681307955
swfLoader 是我加载的 swf 的 swfloader,它加载我编译的 fla。这就是我需要调整大小并定位到中心的内容。接下来的数字是宽度和高度。 FlexLoader 是 swfLoaders 加载器(如果您愿意,也可以是内容)。这些数字是宽度、高度、scaleX 和scaleY。
正如您所看到的,大小是相同的(对于加载的 swfs 应用程序来说也是相同的),但比例不同。两个比例都是根据 1280 和高度 720 计算得出的,这是我编译的 fla 的尺寸。
我搞乱比例的唯一原因是我找不到编译后的 fla 的准确宽度以将其居中(application.width-loadedSwf.width / 2)所以如果有人知道更好的方法来找到我将非常感激! :)
我没有得到的部分是为什么比例不同?我缺少哪一部分? 我完全迷失了,并且已经尝试解决这个问题有一段时间了:p
I have a complicated problem with a couple of SWFLoaders.
I have an application that loads a swf with a SWFLoader. The loaded swf loads another swf (just a compiled fla). I am adding all my resize and position logic in my loaded swf and it works good on event resize, but when I'm trying to run the same code in my swfs applicationComplete it fails. The same code on startup works great if I run my swf as a standanlone, but for some reason the scale is different when I load it into my application.
I'm just setting it's width and height to the browsers size so everything but the scale is the same!
This is my trace from my loaded swf as a standalone:
swfLoader: 1435 742
FlexLoader: 1319.1 742 1.0305555555555554 1.0305555555555554
and this is from the same loaded swf when it's loaded in my application:
swfLoader: 1435 742
FlexLoader: 1159.55 742 0.9053196681307955 0.9053196681307955
swfLoader is my loaded swf's swfloader that loads my compiled fla. That is what I need to resize and position to the center. The next numbers are width and height. FlexLoader is the swfLoaders loader (or content if you will). The numbers are width, height, scaleX and scaleY.
As you can see the size is the same (this is also the same for the loaded swfs application), but the scale is different. Both scales are calculated from with 1280 and height 720 wich is my compiled fla's size.
The only reason why I'm messing around with scale at all is that I can't find the accurate width of my compiled fla to center it (application.width - loadedSwf.width / 2) So if anybody knows a better way to find that I would appreciate that to very much!! :)
The part I'm not getting is why the scales are different? What part am I missing?
I am completely lost and been trying to solve this for quite some time now :p
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与普通 Flash 显示对象一样,您必须根据项目的内部内容设置项目的大小。如果您将一个 SWF (SWFa) 加载到另一个 (SWFb) 中,并让 SWFb 告诉 SWFa 变宽和变高,Flash 不会扩展 SWFa 的舞台,而是缩放 SWFa 的舞台,除非您已将 SWFa 的 StageScaleMode 调整为StageScaleMode.NO_SCALE。如果您已经这样做了,那么在调整 SWFa 舞台大小时,您仍然需要重新定位 SWFa 舞台上的所有项目,以便项目在舞台增大/缩小时保持居中。
As with normal Flash Display Objects, you must set the size of an item based on its internal contents. If you take a SWF (SWFa) and load it into another (SWFb), and have SWFb tell SWFa to be wider and taller, Flash is not expanding SWFa's stage, it is scaling SWFa's stage, unless you have adjusted the StageScaleMode of SWFa to StageScaleMode.NO_SCALE. If you have done that, you still need to handle repositioning all the items on SWFa's stage when it resizes so that the items remain centered as its stage grows/shrinks.