For one of my recent projects I was running in to an issue where my stage dimensions were equal to 0 (zero). This was only occuring when I was referencing the dimensions within a class file that was not within my document class. The only fix that I have found was the need to add an event listener ADDED_TO_STAGE to the class file.
My class file looked like:
package {
import flash.display.Sprite;
import flash.events.Event;
public class MyClass extends MovieClip {
public function MyClass()
{
addEventListener ( Event.ADDED_TO_STAGE , init );
}
private function init(e:Event):void
{
trace ( "Stage Width: " + stage.stageWidth + " -> Stage Height: " + stage.stageHeight );
}
}
}
I was also having this issue. Your fix made the output panel stop whining, but for some reason the trace wouldn’t go through. How are you calling your class?
Hi Jonathan,
This class was used as a sub class to the Main class.. depending on your structure, you may want to take a look at this post:
http://manewc.com/2008/09/05/getting-stagewidth-and-stageheight/
Let me know if there are remaining issues.
-Morgan