Flex:无法调整外部加载的 SWF 内容的大小
我有一个应用程序,我尝试加载外部 SWF。因此,我们有:
- 我的应用程序:舞台的尺寸为 768x1280。缩放模式 = EXACT_FIT。
- 外部SWF:这是另一个应用程序,其阶段为:800x600。缩放模式 = EXACT_FIT。
问题是,尽管我应用“scaleX、scaleY”、更改其宽度等,但外部 SWF 并未修改其大小。 我还尝试将其插入 Canvas 容器中(如“如何调整外部 SWF 的大小以适合容器?”),但它没有解决我的问题。 有趣的代码是当我的应用程序加载外部 SWF 时:
private function onLoadedApp( evt:Event ):void{
stage.scaleMode = StageScaleMode.EXACT_FIT;
trace("Loading Application..");
var loaderInfo:LoaderInfo = evt.target as LoaderInfo;
loaderInfo.removeEventListener( Event.COMPLETE, onLoadedApp);
trace(loaderInfo.loader.content);
var swfApplication:SpriteUIComponent = new SpriteUIComponent(evt.target.loader.content );
if( SWFContainer.width < swfApplication.explicitWidth ){
var coef:Number = SWFContainer.width/swfApplication.explicitWidth;
swfApplication.scaleX = coef;
swfApplication.scaleY = swfApplication.scaleX;
}
SWFContainer.addElement(swfApplication);
}
我也尝试通过 SWFLoader 来执行此操作,但尽管我添加了“scaleContent”参数,但 external.swf 的内容并没有改变其原始大小。
我得到的视觉结果:
外部 SWF 已加载到合适的位置,并且“似乎”具有 320x240 的暗度。但它的宽度有点被裁剪,因为如果我拉伸 Flash Player,我就能看到外部 swf 舞台的其余部分。此外,尽管我收缩/拉伸 Flash Player,但外部 SWF 的大小从未调整。它始终保持固定(如果我追踪其尺寸,我总是得到 800x600,尽管我在视觉上看到 320x240) - 如果我增加主应用程序的舞台宽度,这个小剪辑就会消失。
讨论:
我知道原始Stage的尺寸是800,这比我的应用程序的原始Stage(768)大,但我认为,当我调整大小时,外部SWF的Stage必须安装在容器中。它已安装,但看不到外部 SWF 的一部分。就像 Flash Player 记得外部 SWF 舞台的宽度大于我的应用程序的宽度一样...
提前致谢。
I have an application where I try to load an external SWF. So, we have:
- My application: The Stage's dimensions are 768x1280. ScaleMode = EXACT_FIT.
- External SWF: It's another application where its stage is: 800x600. ScaleMode = EXACT_FIT.
The problem is that the external SWF does not modify its size although I apply "scaleX, scaleY", change its width and so on.
I also tried to insert it into a Canvas container (as "How to resize an external SWF to fit into a container?" ) but it didn't solve my problem.
The interesting piece of code is when the external SWF is loaded by my application:
private function onLoadedApp( evt:Event ):void{
stage.scaleMode = StageScaleMode.EXACT_FIT;
trace("Loading Application..");
var loaderInfo:LoaderInfo = evt.target as LoaderInfo;
loaderInfo.removeEventListener( Event.COMPLETE, onLoadedApp);
trace(loaderInfo.loader.content);
var swfApplication:SpriteUIComponent = new SpriteUIComponent(evt.target.loader.content );
if( SWFContainer.width < swfApplication.explicitWidth ){
var coef:Number = SWFContainer.width/swfApplication.explicitWidth;
swfApplication.scaleX = coef;
swfApplication.scaleY = swfApplication.scaleX;
}
SWFContainer.addElement(swfApplication);
}
I also tried to do it through SWFLoader, but the external.swf's content doesn't change its original size although I add the "scaleContent" parameter.
Visual results I got:
The external SWF is loaded on the suitable position and it "seems" to have 320x240 dim. But its width is a bit cropped, since if I stretch the Flash Player I achieve to see the rest of the external swf's stage. Besides, the external SWF never is resized although I shrink/stretch the Flash Player. It always remains fixed (if I trace its dimensions, I always get 800x600, although I visually see 320x240)- If I increase the stage's width of the main application, this little clip dissapear.
Discussion:
I know the original Stage's dimensions are 800, and this is greater than the original stage of my application (768), but I think, when I do the resizing, external SWF's Stage have to be fitted in the container. It is fitted, but a part of the external SWF is not seen. It's like Flash Player remembered that the external SWF Stage's width were greater than my application's one...
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
即使将scaleContent 设置为“true”,您仍然需要为SWFLoader 控件设置精确的高度和宽度,以便它尝试调整内部SWF 的大小。 scaleContent 所做的一切不是以常规或拉伸尺寸显示 SWF,如果需要,它还会放大 SWF,如果不只是缩放以保留原始 SWF 的比例。
Even with scaleContent set to "true" you still need to set an exact height and width to the SWFLoader control for it to even try resizing the internal SWF. All scaleContent does is instead of showing the SWF at regular or stretched sizes, it also up-scales the SWF if needed, and if not just scales it to retain the ratio of the original SWF.
我认为问题不在于您的 ScaleMode。每个 Flash 播放器只能有一个阶段。 “外部”SWF 的“stage”属性在“应用程序”SWF 添加到显示列表后引用其阶段。如果 SWF 已加载但未添加到显示列表中,则加载的 SWF 的“stage”属性将等于“null”。在外部 SWF 中设置舞台 scaleMode 不会决定加载到另一个 SWF 后它如何缩放。
另外,您可能正在调整 SWFContainer 的大小,而不是 SWF 本身的大小...这就是为什么 SWF 宽度和高度属性始终为 800x600。我不确定这是否是您所要求的,但据我了解,您可能需要创建一个舞台调整大小事件侦听器。
I don't think the issue is with your ScaleMode. There can only be one Stage per flash player. The "stage" property of your 'external' SWF references the Stage of your 'application' SWF after it's added to the display list. If the SWF is loaded and not added to the display list, the loaded SWF's 'stage' property will equal 'null'. Setting the stage scaleMode inside your external SWF won't dictate how it scales once loaded into another SWF.
Also, you're probably resizing the SWFContainer, not the SWF itself...thats why the SWF width and height properties are always 800x600. I'm not sure if this is what you're asking for, but from what I'm understanding, you may need to create a stage resize event listener.
您是否尝试过在“外部 SWF”上使用缩放效果?
缩放效果
Have you tried to use a scale effect on "External SWF"?
Scale Effect