2 Replies Latest reply on Sep 12, 2010 1:05 PM by fagagou

    how to get height of the screen ?

    fagagou

      Hy, i am coding a desktop app and i need to get dimensions of the screen to display some object. This is my code:

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
           <mx:Script>
                <![CDATA[
                     import mx.controls.Alert;
                     
                     public var currentScreen:Screen;
                     
                     public function init():void {
                          Alert.show(currentScreen.bounds.height.toString());
                     }
                     
                ]]>
           </mx:Script>
      </mx:WindowedApplication>

       

      It is compiled without problembut when i run the code i have an error:

       

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
           at test/init()[C:\Users\faraj\Documents\Flex Builder 3\test\src\test.mxml:10]
           at test/___test_WindowedApplication1_creationComplete()[C:\Users\faraj\Documents\Flex Builder 3\test\src\test.mxml:2]
           at flash.events::EventDispatcher/dispatchEventFunction()
           at flash.events::EventDispatcher/dispatchEvent()
           at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9298]
           at mx.core::UIComponent/set initialized()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:1169]
           at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:718]
           at Function/http://adobe.com/AS3/2006/builtin::apply()
           at mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8628]
           at mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8568]

       

       

      please, what does it mean ?

       

      thanks !