RSS
 

Flash CS3 ’stage.stageHeight’ Bug

11 Aug

If you’ve developed for Flash for any amount of time, you’ll have noticed Flash has some annoying bugs. Last night, I learned of a new one. It took a while to narrow down with the amount of code I was working through and, as usual, I assumed it was something I was doing wrong.

In ActionsScript 3.0, to get the height of the stage you’d use ’stage.stageHeight.’ In my case, I was working with a 600 x 400 Flash file with movieclips that needed to be vertically centered. After publishing, the vertically centered elements were not centered properly. This led me to re-examine my code and math quite heavily. Nothing appeared to be in error. Tracing out ’stage.stageHeight’ reported back a height of 300. This was obviously wrong since my project was 400 pixels tall. Resizing the stage to 300 made my trace report back a height of 200. I reset my stage to 400 tall and thought about the problem. So everything was off vertically by 100 pixels. Odd.

On a whim I did a test movie.  I then, ever-so-slightly, resized the preview window and hit the ‘test movie’ hot key again. A had adjusted the window only a few pixels. Instead of reporting back, say, 303 pixels it was now reporting 403 pixels. Ah-hah! Now I had an idea what was wrong: Flash was being a pain in the butt. Continuing my whim, I turned off the bandwidth profiler I often leave open and recompiled . . . 400! Stupid Flash! The bandwidth profiler seems to have an issue eating up vertical pixels.  Bad Flash.  Very, very bad.

Share and Enjoy:
  • Print
  • email
  • Facebook
  • LinkedIn
 

Tags: , , , , , ,

Leave a Reply

 
 
  1. anony

    November 10, 2008 at 6:58 pm

    Thanks so much, I’ve been banging my head for hours wondering what I was doing wrong!

     
  2. Russell Munro

    April 9, 2009 at 12:51 am

    I suspect you just saved me many hours of pain. Thanks heaps!

     
  3. Federico Contreras

    October 27, 2009 at 2:49 pm

    I just bumped into this as well, the fact that this bug is still around is hilarious, I don’t have CS4 here yet, can anyone confirm whether or not it exists in there too?

    I also suspect you saved me a whole bucketload of trouble … Many, many thanks for confirming that it is indeed a flash bug.