[英]Problem resizing loader after loading swf
I'm using the following code to load an swf in a pure actionscript project (Flex Builder 3) 我正在使用以下代码在纯ActionScript项目(Flex Builder 3)中加载swf
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, Loader_Complete);
_loader.contentLoaderInfo.addEventListener(Event.INIT, Loader_Init);
var request:URLRequest = new URLRequest("Skins/TestSkin.swf");
_loader.load(request);
this.addChild(_loader);
This works okay and displays the swf on the stage (500x375 for some reason - not sure why, TestSkin.swf is a flex app with no defined width and height) 这样可以正常工作,并在舞台上显示swf(出于某种原因500x375-不确定为什么,TestSkin.swf是没有定义宽度和高度的Flex应用程序)
However, when I try to scale the swf so that it will fill the stage, I have problems. 但是,当我尝试缩放swf以使其充满舞台时,我遇到了问题。
I have tried: 我努力了:
I have seen examples online where people say these work for them but whenever I set width or height in any of these ways, the loaded swf is simply not displayed at all. 我在网上看到了一些例子,人们说这些对他们有用,但是每当我以任何这些方式设置宽度或高度时,根本不会显示加载的swf。
Any idea what could be causing this? 知道是什么原因造成的吗?
What is the correct way to resize an swf that has been loaded with a Loader object? 调整已加载Loader对象的swf大小的正确方法是什么?
I have found a workaround for my current problem. 我已经找到解决当前问题的方法。
I can add the following event handler to my sub-swf: 我可以将以下事件处理程序添加到子swf中:
public function AddedToStage():void
{
this.width = this.stage.width;
this.height = this.stage.height;
}
and attach it to the addedToStage event of the application. 并将其附加到应用程序的createdToStage事件。
However, I would still like to know how to set the dimensions of the sub-swf from the parent swf - there may be times where I don't have control over the loaded swf so I can't add this code to it. 但是,我仍然想知道如何从父SWF设置子SWF的尺寸-有时我无法控制已加载的SWF,因此无法向其中添加此代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.