Skip to main content
OstrichFarmer
Participant
March 26, 2019
Question

Stage.width undefined in loaded AVM1 movie

  • March 26, 2019
  • 1 reply
  • 437 views

I'm making a desktop AIR app that loads old SWFs (AS2, FP6). Some of these movies make use of the Stage dimensions. Unfortunately, those properties are undefined when the SWF is loaded into the app.

This thread from 11 years ago describes my problem:

Stage.width undefined

Apparently a bug report was filed back then but I can't track it down. Is it possible this was never fixed?

I have over 500 of these old Flash movies, so I'm really hoping to find some solution that doesn't involve editing them.

Any advice appreciated.

This topic has been closed for replies.

1 reply

OstrichFarmer
Participant
March 27, 2019

With further research I found that not all old SWFs are affected. For example, a SWF published for FP9/AS1 will have its stage dimensions defined. But there are still two bugs:

- Sometimes the dimensions are <0,0>. This has occurred randomly, on multiple occasions.

- The dimensions will be for the stage of the original window, even if the Loader is attached to a different window's stage. (I'm loading the old SWFs in their own NativeWindows.)

So I can answer my original post: AVM1 movies loaded in AIR apps can not safely use Stage.width or Stage.height.

Inspiring
March 27, 2019

you can parse the bytes of the loaded SWF to find out the width and height yourself

OstrichFarmer
Participant
March 27, 2019

Interesting idea. Thanks for the suggestion.

Fortunately, in this project I already have a table with file names and movie sizes. The AIR app has no problem creating a correctly sized window and loading a SWF into it.

Everything works great, except when an old AS1 or AS2 movie loaded this way uses Stage.width or Stage.height. Depending on which SWF version the movie was published as, these values will either be undefined, <0,0>, or the stage dimensions for the wrong window (the initial window).

And by "old", I mean that some of these movies date back to the Macromedia days. An example problem: the Flash MX combobox (ca. 2002) will always open up if Stage.height is undefined, sometimes causing its contents to be rendered off-screen. Fixing that once is easy, fixing it hundreds of times is going to be a chore.