Problem resizing loader after loading swf

放肆的年华 提交于 2020-01-05 08:09:30

问题


I'm using the following code to load an swf in a pure actionscript project (Flex Builder 3)

_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)

However, when I try to scale the swf so that it will fill the stage, I have problems.

I have tried:

  • Setting _loader.width and _loader.height in my Loader_Complete handler
  • Setting _loader.width and _loader.height in my Loader_Init handler
  • Setting _loader.content.width and loader.content.height in my Loader_Complete handler
  • Setting _loader.content.width and loader.content.height in my Loader_Init handler

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.

Any idea what could be causing this?

What is the correct way to resize an swf that has been loaded with a Loader object?


回答1:


I have found a workaround for my current problem.

I can add the following event handler to my sub-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.

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.



来源:https://stackoverflow.com/questions/2780445/problem-resizing-loader-after-loading-swf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!