Jump to content


LoaderMax scaleMode:"proportionalInside" fails with swfobject

Recommended Posts

When loading a movie using swfobject and dynamically setting the dimensions of the stage the scaleMode:"proportionalInside" fails.


Any ideas on this ?



While we are at it, SWFloader with AVM1 clips also throws errors when trying to use standard commands - there are work arounds for this I would have thought would have been in the class ?

Link to comment
Share on other sites

Hm, I'm not aware of any bugs in SWFLoader that would cause AVM1 clips to throw errors, but I'd really like to resolve those if they exist - could you post a very simple example that demonstrates the problem? Same for the "proportionalInside" failing thing you mentioned. I wonder if maybe you expected it to scale to adjust for you stretching the actual stage (which could happen if you stretch the swf in the browser and don't set the stage's scaleMode to be none).


For example, if you set a with width/height of the SWFLoader (well, it's ContentDisplay technically) to be 100x100 and you load in an image that is 200x100 with a scaleMode of "proportionalInside", it will indeed scale that image to be 100x50 so that it fits inside that area. If, however, you stretch the stage itself so that the native pixel dimensions are no longer square, that doesn't change the width/height of the ContentDisplay, so it would have no reason to change your image dimensions accordingly.


Think of it like putting a square inside a Sprite and then stretching that sprite so that its scaleX is 2 and scaleY is 1 - that square would appear to be a rectangle now, but if you measured its width/height in its local dimensions (in the Sprite), it would still report as being square.


Does that clear things up?

Link to comment
Share on other sites

Hi jack,

Removed the play() call from the avm1 class, it was a loaded swf which I had no access to, the others I had created to test and worked. Basically I let them all play, so I can not test it and resolve the issue. Sorry.


The issue with the "proprtionalInside" which you pointed was correct, however I required the ability to load any asset into a fixed aspect (10x10) which could be dynamically set with swfobject and to any dimension and have the assets internally resize to fit that potentially random configuration - I used to use the DisplayUtils package I found years ago - but nothing worked as the stage was being stretched.


How does one determine things ??


My head almost exploded at the end, as I was sure it was a really simple fix somewhere and was determined to find it - couldn't and ended up writing this HEINOUS function



private function setSize() : void {
var targ:DisplayObject=holder.getChildByName(media[counter].value);
if(displayWidth / targ.width >= displayHeight / targ.height) {
var sc : Number = (stage.stageHeight / targ.height);
targ.width *= (stage.stageHeight / targ.height);
targ.height = stage.stageHeight;
if(targ.height > targ.width && (displayHeight/displayWidth)>1) {
} else {
targ.height *= (stage.stageWidth / targ.width);
targ.width = stage.stageWidth;
if(targ.width > targ.height && (displayWidth/displayHeight)>1) {
private function setPositions(targ : DisplayObject) : void {
TweenMax.to(targ, 0, {x:(targ.width - stage.stageWidth) * -.5, y:(targ.height - stage.stageHeight) * -.5})
targ.alpha = .5;

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.