views:

295

answers:

2

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?

A: 

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.

DanK
A: 

Can you give me more explanation please ?

Kevin
what do you want more explanation of?
DanK