2 Replies Latest reply on Aug 6, 2010 8:27 PM by Noppadon Sodram

    Alert control problem in loaded module.

    Noppadon Sodram Level 1

      I have 2 problem on Flex 4 about Alert control on loaded module.

       

      1.
      I create my Flex 4 web app but can not display Alert control in loaded Module.
      When I click Button in Module then appear some error message like this.

       

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
          at mx.managers::PopUpManagerImpl/http://www.adobe.com/2006/flex/mx/internal::createModalWindow()[E:\dev\4.0.0\frameworks\pr ojects\framework\src\mx\managers\PopUpManagerImpl.as:682]
          at mx.managers::PopUpManagerImpl/addPopUp()[E:\dev\4.0.0\frameworks\projects\framework\src\m x\managers\PopUpManagerImpl.as:397]
          at mx.managers::PopUpManager$/addPopUp()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\m anagers\PopUpManager.as:193]
          at mx.controls::Alert$/show()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\controls\Ale rt.as:618]
          at modules_alert::Module_Alert/button1_clickHandler()[/Users/noppadonsodram/Documents/Adobe Flash Builder 4/Alert_Test/src/modules_alert/Module_Alert.mxml:13]
          at modules_alert::Module_Alert/___Module_Alert_Button1_click()[/Users/noppadonsodram/Documen ts/Adobe Flash Builder 4/Alert_Test/src/modules_alert/Module_Alert.mxml:27]

       


      My code like this.

       

      <?xml version="1.0" encoding="utf-8"?>
      <!-- Alert_Test.mxml -->
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
          <fx:Script>
              <![CDATA[
                  import mx.controls.Alert;
                  import mx.modules.ModuleLoader;
                 
                  protected function button1_clickHandler(event:MouseEvent):void
                  {
                      // TODO Auto-generated method stub
                      var bxChild:Box = new Box();
                      var mdl:ModuleLoader = new ModuleLoader();
                      mdl.url = "modules_alert/Module_Alert.swf";
                      mdl.loadModule();
                     
                      bxChild.addChild( mdl );
                     
                      bx.addChild( bxChild );
                  }

       

              ]]>
          </fx:Script>
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
             
          </fx:Declarations>
         
         
          <mx:Box id="bx">
              <s:Button click="button1_clickHandler(event)"/>
          </mx:Box>
         
         
      </s:Application>

       

      <?xml version="1.0" encoding="utf-8"?>
      <!-- modules_alert/Module_Alert.mxml -->
      <mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
                 xmlns:s="library://ns.adobe.com/flex/spark"
                 xmlns:mx="library://ns.adobe.com/flex/mx">

       

          <fx:Script>
              <![CDATA[
                  import mx.controls.Alert;
                  protected function button1_clickHandler(event:MouseEvent):void
                  {
                      txt.text = 'Hello module'; // It work.
                      Alert.show('Hello module','xx',Alert.OK, this); // Error here.
                      try{
                          txt.text += 'Hello module in try{}'; // It work.
                          mx.controls.Alert.show('Hello module'); // Can't action in try{}
                      }catch( err:Error ){
                         
                      }
                  }
              ]]>
          </fx:Script>

       

          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
          <s:Button click="button1_clickHandler(event)"/>
          <mx:Text id="txt"/>
      </mx:Module>

       

       


      How I can use Alert control?

       

      2.
      I develop my code from Flex 3 web app to Flex 4 it can display Alert control in loaded Module but display on top side like this.

      Untitled.png
      How I can set Alert control to show at center?

        • 1. Re: Alert control problem in loaded module.
          Flex harUI Adobe Employee

          See the release notes.  Managers need to be linked into the main app

          1 person found this helpful
          • 2. Re: Alert control problem in loaded module.
            Noppadon Sodram Level 1

            Brillion Thanks. Flex harUI

             

            I read release note and I add some code call Alert control in main application like this.

             

                        protected function button1_clickHandler(event:MouseEvent):void
                        {
                            // TODO Auto-generated method stub

                            new Alert(); // Add this or below

                            Alert.show('something if you module use Alert.show()'); // Add this then can use Alert control module

                           
                            var bxChild:Box = new Box();
                            var mdl:ModuleLoader = new ModuleLoader();
                            mdl.url = "modules_alert/Module_Alert.swf";
                            mdl.loadModule();
                           
                            bxChild.addChild( mdl );
                           
                            bx.addChild( bxChild );
                        }