Tinelise
Tinelise

Reputation: 23

AS3: Setting size of loaded swf

I'm using Loader to load an external swf into my swf and adding that loaded swf to the stage using event.target.content.

If i set the width and height of the loaded swf I actually resize the movieclip inside my loaded swf. What I wanna do is change the stage size of the loaded swf.

Any way of doing that?

Upvotes: 2

Views: 7779

Answers (1)

danjp
danjp

Reputation: 727

The best way to find the scale you need is to compare the ratios of the width and height scales of the content and the target. To make the loaded swf fit within the area, scaling so that everything is inside you can do something like this:

var scale:Number = Math.min( _holder.width / _loader.content.width,
                            _holder.height / _loader.content.height );
_loader.content.scaleX = _loader.content.scaleY = scale;

This will make sure that you can see everything. If you change Math.min to Math.max, you will get a different result if the dimensions don't match

Upvotes: 1

Related Questions