简体   繁体   English

Flex:无法调整外部加载的SWF内容的大小

[英]Flex: Impossible to resize the external loaded SWF's content

I have an application where I try to load an external SWF. 我有一个应用程序,我尝试加载外部SWF。 So, we have: 所以,我们有:

  • My application: The Stage's dimensions are 768x1280. 我的应用:舞台的尺寸为768x1280。 ScaleMode = EXACT_FIT. ScaleMode = EXACT_FIT。
  • External SWF: It's another application where its stage is: 800x600. 外部SWF:它是另一个应用程序,其阶段是:800x600。 ScaleMode = EXACT_FIT. 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. 问题是外部SWF不会修改它的大小,虽然我应用“scaleX,scaleY”,改变其宽度等等。 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. 我还尝试将其插入到Canvas容器中(如“如何调整外部SWF大小以适应容器?”)但它并没有解决我的问题。 The interesting piece of code is when the external SWF is loaded by my application: 有趣的代码是当我的应用程序加载外部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);
}

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. 我也试过通过SWFLoader来做,但是external.swf的内容并没有改变它的原始大小,尽管我添加了“scaleContent”参数。

Visual results I got: 我得到的视觉效果:

The external SWF is loaded on the suitable position and it "seems" to have 320x240 dim. 外部SWF加载在合适的位置,“看起来”是320x240暗淡。 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. 但它的宽度有点裁剪,因为如果我拉伸Flash Player,我会看到外部swf的其余部分。 Besides, the external SWF never is resized although I shrink/stretch the Flash Player. 此外,虽然我缩小/拉伸Flash Player,但外部SWF永远不会调整大小。 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. 它总是保持固定(如果我追踪其尺寸,我总是得到800x600,虽然我在视觉上看到320x240) - 如果我增加主应用程序的舞台宽度,这个小剪辑消失。

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. 我知道舞台的原始尺寸是800,这比我应用的原始阶段(768)要大,但我认为,当我进行调整大小时,外部SWF的舞台必须安装在容器中。 It is fitted, but a part of the external SWF is not seen. 它适合,但没有看到外部SWF的一部分。 It's like Flash Player remembered that the external SWF Stage's width were greater than my application's one... 就像Flash Player记得外部SWF Stage的宽度大于我的应用程序的宽度......

Thanks in advance. 提前致谢。

Have you tried to use a scale effect on "External SWF"? 您是否尝试对“外部SWF”使用缩放效果?

Scale Effect 规模效应

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. 即使scaleContent设置为“true”,您仍需要为SWFLoader控件设置精确的高度和宽度,以便它甚至可以尝试调整内部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. 所有scaleContent都不是以常规尺寸或拉伸尺寸显示SWF,而是在需要时对SWF进行升级,如果不是,只需按比例缩放以保持原始SWF的比例。

I don't think the issue is with your ScaleMode. 我认为问题不在于您的ScaleMode。 There can only be one Stage per flash player. 每个Flash播放器只能有一个舞台。 The "stage" property of your 'external' SWF references the Stage of your 'application' SWF after it's added to the display list. “外部”SWF的“stage”属性在将“应用程序”SWF添加到显示列表后引用该阶段。 If the SWF is loaded and not added to the display list, the loaded SWF's 'stage' property will equal 'null'. 如果SWF已加载但未添加到显示列表,则加载的SWF的“stage”属性将等于“null”。 Setting the stage scaleMode inside your external SWF won't dictate how it scales once loaded into another SWF. 在外部SWF中设置stage scaleMode将不会决定它在加载到另一个SWF后如何缩放。

Also, you're probably resizing the SWFContainer, not the SWF itself...thats why the SWF width and height properties are always 800x600. 此外,您可能正在调整SWFContainer的大小,而不是SWF本身...这就是为什么SWF宽度和高度属性始终为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. 我不确定这是否是你所要求的,但根据我的理解,你可能需要创建一个舞台调整大小事件监听器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM