I suspect that an Application dispatches a "resize" event when it is first created and sized, but before it is onstage, so 'stage' is null when it is first called.
You could just make resizeHandler() return if stage is null. Or you could delay listening for "resize" events until the application dispatches an applicationComplete event. Gordon Smith Adobe Flex SDK Team From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of markflex2007 Sent: Wednesday, January 06, 2010 7:19 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] how to use stage in mxml I try to get current stage size with the code,but I get error "TypeError: Error #1009: Cannot access a property or method of a null object reference.". It seems I get error for stage.height. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationPolicy="all" resize="resizeHandler(event)"> <mx:Script> <![CDATA[ import mx.events.ResizeEvent; private function resizeHandler(event:ResizeEvent):void{ trace("height:" + stage.height); trace("height:" + stage.width); } ]]> </mx:Script> ... ... </mx:Application> Please help me.Thanks Mark