Skip to main content
Inspiring
March 27, 2007
Question

Need to find "real" width/height of loaded SWF

  • March 27, 2007
  • 3 replies
  • 205 views
So, I'm creating a player that will eventually be able to play back both FLV and SWF files. While testing the SWF functionality, I noticed some funkiness with resizing the SWF once loaded into a movieClip.

Yes, I already do know that loading (via MovieClipLoader) needs to have finished before I can get the actual width and height of the SWF in question... that's not the issue.

The issue is that I will not know ahead of time what the SWF dimensions are. Which should be ok, as long as I can get accurate dimensions after the SWF has loaded. However, I do not have control over the source SWFs - they could come from anywhere (many content providers), and in the event that the remote SWF uses masking, the width and height may not quite be accurate.

Here is an example - as a test, I have my player load http://www.magicarchive.com/jawsbunnies.swf into a movieclip via MovieClipLoader. Peachy-keen, it works. I then want to resize the movieclip to be 400px wide by 300 tall. Doing this by setting _width and _height (or _xscale and _yscale) makes the visible area of the movie too small because of masking or whatever (before scaling, tracing _width and _height on the source movie shows width = 856.4 and height = 637.45... after resizing the swf in a movieclip to 400wide x 300 tall, the actual visible movie seems to be more like 334wide x 254tall). I can't even center the smaller-than-I-want-it-to-be clip because I can't determine its real width.

So, how might I find the "real" width/height of the visible area? Is it a case of requiring some accompanying metadata from my SWF providers? I've also tried using hitTest, and while the hitTest area is slightly smaller than the width and height, it is still slightly larger than the real visible dimensions, so testing the hittable area to determine the visible area won't work, either. I'd like to try determining SWF dimensions without having to bother providers, though.

When I put this same SWF into an HTML page with Dreamweaver, it automatically sizes to 720x540, which seems to be the "real" visible dimensions. How do I get to those dimensions once the SWF is loaded into a movieClip, though?

Thanks for any help.
This topic has been closed for replies.

3 replies

Inspiring
March 27, 2007
BTW, I'm using Flash 8/AS2. If this cannot be done in Flash 8, will it change for Flash 9/AS3?

Thanks again for any help.
Inspiring
March 27, 2007
Doh. I read in another post that "there is no way to determine what size at which an SWF was exported".

So, there is no way I can determine the real visible dimensions of an SWF I have no control over?

It seems like there SHOULD be a way to do this - since for example, if I embed an SWF into an HTML page (via Dreamweaver), Dreamweaver automatically determines the correct "Stage" size. This is what I need to do, only within AS...
Inspiring
March 27, 2007
It seems that ideally, if I could find the equivalent of Stage.width and Stage.height of the original SWF, that should work. But since the SWF is imported into a movieClip, not sure how I'd go about finding those properties.