Search code examples
apache-flexactionscriptflashfla

How do I get the position of a swf generated from an fla file that had a larger stage?


I have assets in external swfs which I load. I would like to know the exact size of the stage and the position of the asset in the fla that created it. If I try to ask the resulting MovieClip for it's size, it turns out it gives me the size when it is trimmed down to the tightest box around the non-transparent pixels. Looking at the contentLoaderInfo, I can get the original width/height that was used by the fla file, which is great. However, I still need to know where to place the asset within the stage.. basically I need an x/y offset for it.

The reason I need this is for a customizable avatar - it has many parts, which are placed in different areas on a stage to create the full avatar. I would like to be able to combine the individual swfs for each part to achieve this.

Thanks in advance for any help!


Solution

  • I don't believe you can get the stage size of a loaded swf, as there is only one stage in flash when you load a child swf in, it will use the parent stage. As you pointed out a loaded swf will collapse to the bounding box of the items within it.

    Might I suggest that all assets have a MovieClip on the stage containing a block the dimensions of the stage, then change the alpha of this clip to 0 so it isn't visible.