views:

535

answers:

2

I have a flash file I want to programatically find the dimensions of in my code. Right at the beginning of the code I have the string:

[SWF(width='700', height='500')]

And several subclasses later I want to pull these "700" and "500" values up as variables.

Is there a way to find this?

I've tried referencing this.width and this.height but they always end up zero for the parent canvas.

Referencing the Stage does not work as it returns the current stage size, not the desired size. For example, if I load the SWF directly and not through a browser, I can scale the viewport to be as big or small as I like.

A: 

Turns out my original answer was wrong, check this out for a very similar question: http://stackoverflow.com/questions/245420/dimensions-of-loaded-swfs-stage

grapefrukt
+1  A: 

stage.stageWidth and stage.stageHeight will refer to the full width and height of the stage. It will change at runtime if the instance of Flash Player changes size. There's also loaderInfo.width and loaderInfo.height, which should tell you the original values specified in the [SWF] metadata, and they won't change at runtime.

joshtynjala
Ah perfect. I had to add an Event.INIT to catch loaderInfo after it was finished loading, but it did the trick! thanks.
Andy Moore