Internet Explorer 6 is not supported.
Upgrade to view this site.

Get Loaded SWF File Dimensions

Posted on April 29, 2009 at 9:57 pm

When externally loading a SWF, the file is casted to a MovieClip object. The top left position is preserved when it loads in but you lose a few things that could be helpful. First of all your background color is gone (As far as I know). This is the color that is set in the Properties panel in Flash or the SWF meta tag in Flex. The other thing is that the dimensions aren’t preserved either. If you trace the SWF file’s width and height it will return the width and height of content inside and not the bounding of the original SWF file. But there is somewhere that this information is preserved. Inside the LoaderInfo object. To obtain the size of the loaded object just write something like this. This short example is an example of snytax and is not actual functional code.

1
trace(extFile.loaderInfo.width + " " + extFile.loaderInfo.height);

There is the other information that the LoaderInfo object retains like actionscriptVersion and frameRate. A full list can be found in the reference guide. Like everything else AS3.

Leave a Comment

*Required fields. Email will not be published.