3 Replies Latest reply on Mar 27, 2007 12:15 PM by liquidleaf

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

    liquidleaf Level 1
      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.