8 Replies Latest reply on Sep 28, 2011 1:01 PM by Flex harUI

    Help me,About invoking PopUpManager.addPopUp problem in Flex 4 Module

    bhluo

      hello,when I invoke PopUpManager.addPopUp(),have a problem. detail from the fellowing program code;

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
                 xmlns:s="library://ns.adobe.com/flex/spark" width="100%" height="100%"
                 xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="initApp()">
          <fx:Declarations>
              <!-- 将非可视元素(例如服务、值对象)放在此处 -->
          </fx:Declarations>
         
          <fx:Script>
              <![CDATA[
                  import mx.collections.ArrayCollection;
                  import mx.controls.Alert;
                  import mx.core.FlexBitmap;
                  import mx.core.FlexGlobals;
                  import mx.events.CloseEvent;
                  import mx.events.DataGridEvent;
                  import mx.events.ListEvent;
                  import mx.managers.PopUpManager;
                  import mx.rpc.AsyncToken;
                  import mx.rpc.events.FaultEvent;
                  import mx.rpc.events.ResultEvent;
                  import mx.rpc.remoting.RemoteObject;
                 
                  import org.mydev.fnd.proxy.FndLookupHeadersProxy;
                  import org.mydev.fnd.proxy.FndLookupLinesProxy;
                  import org.mydev.fnd.vo.FndLookupHeadersVO;
                  import org.mydev.fnd.vo.FndLookupLinesVO;
                  import org.mydev.utils.PublicFunction;
                 
                  import spark.components.Application;
                  [Bindable]
                  private var myac:ArrayCollection=new ArrayCollection();
                  [Bindable]
                  private var myacLines:ArrayCollection=new ArrayCollection();
                  private var headerProxy:FndLookupHeadersProxy=new FndLookupHeadersProxy();
                  private var linesProxy:FndLookupLinesProxy=new FndLookupLinesProxy();
                  private var add:FndHeaderDM;
                  private var lineAdd:FndLineDM;
                 
                  private function lfRowNum(oItem:Object,iCol:int):String
                  {
                      var iIndex:int = myac.getItemIndex(oItem) + 1;
                      return String(iIndex);
                  }
                 
                  private function lfRowNumLines(oItem:Object,iCol:int):String
                  {
                      var iIndex:int = myacLines.getItemIndex(oItem) + 1;
                      return String(iIndex);
                  }
                 
                  private function we_resultHandler(event:ResultEvent):void
                  {
                      myac=event.result as ArrayCollection;
                      //                PopUpManager.removePopUp(wi);
                      // TODO Auto-generated method stub
                  }
                 
                  private function we_faultHeadler(event:FaultEvent):void{
                      //                var msg:String=event.message.toString();
                      Alert.show("插入数据失败!");
                  }
                 
                  private function we_resultHandlerLines(event:ResultEvent):void
                  {
                      myacLines=event.result as ArrayCollection;
                      //                PopUpManager.removePopUp(wi);
                      // TODO Auto-generated method stub
                  }
                 
                  private function we_faultHeadlerLines(event:FaultEvent):void{
                      //                var msg:String=event.message.toString();
                      Alert.show("插入数据失败!");
                  }
                 
                  public function initApp():void{
                      dataHeaders.allowMultipleSelection=true;
                      var token:AsyncToken=headerProxy.getAllHeaders();
                      PublicFunction.addResponder(token,we_resultHandler,we_faultHeadler);
                      //                dataHeaders.addEventListener(MouseEvent.DOUBLE_CLICK,doubleClick)
                      //                dataHeaders.addEventListener(ListEvent.KEY_DOWN,selectChange);
                  }
                 
                 protected function btnAddHeader_clickHandler(event:MouseEvent):void
                  {
                      //                trace("test.............");
                      add=new FndHeaderDM();
                      PopUpManager.addPopUp(add,parent,true);
                      //PopUpManager.addPopUp(add,FlexGlobals.topLevelApplication as DisplayObject,true);
                      PopUpManager.bringToFront(add);
                      PopUpManager.centerPopUp(add);
                      //                var myFun:Function=initApp;
                      var fndLookupHeadersVO:FndLookupHeadersVO=new FndLookupHeadersVO();
                      add.init(fndLookupHeadersVO,1,myac);
                  }

                 
                 
                  private function headerAlertClickHandler(event:CloseEvent):void { 
                      var myObj:FndLookupHeadersVO=(FndLookupHeadersVO)(dataHeaders.selectedItem);
                      if (event.detail==Alert.YES){  
                          //                    Alert.show("你选择了 确定");  
                          myac.removeItemAt(dataHeaders.selectedIndex);   
                         
                         
                          //this.parent.removeChildAt(dataHeaders.selectedIndex);
                          headerProxy.removeObj(myObj);
                          //                initApp();
                          //dataHeaders.initialize();
                         
                      }
                      //                else if(event.detail==Alert.NO){  
                      //                    Alert.show("你选择了 否");  
                      //                }else{  
                      //                    Alert.show("你选择了 取消");  
                      //            }
                     
                  }
                 
                 
                  protected function btnDelHeader_clickHandler(event:MouseEvent):void
                  {
                      if (dataHeaders.selectedItem!=null){
                          Alert.show("是否要删除?", "信息提示",3, this, headerAlertClickHandler);
                      }else{
                          Alert.show("请选定一条记录进行操作!", "信息提示");
                      }
                      //                PublicFunction.confirmDelete(dataHeaders.selectedItems,secondAlertClickHandler);
                  }
                 
                 
                  protected function btnEditHeader_clickHandler(event:MouseEvent):void
                  {
                      if (dataHeaders.selectedItem!=null){
                          var myObj:FndLookupHeadersVO=(FndLookupHeadersVO)(dataHeaders.selectedItem);
                          add=new FndHeaderDM();
                          PopUpManager.addPopUp(add,parent,true);
                          PopUpManager.bringToFront(add);
                          PopUpManager.centerPopUp(add);
                          add.init(myObj,2,myac);
                      }else{
                          Alert.show("请选定一条记录进行操作!", "信息提示");
                      }
                  }
                 
                  protected function dataHeaders_changeHandler(event:ListEvent):void
                  {
                      //                Alert.show(myac.getItemAt(dataHeaders.selectedIndex)+"");
                      var myObj:FndLookupHeadersVO=(FndLookupHeadersVO)(myac.getItemAt(dataHeaders.selectedIndex));
                      var myLineObj:FndLookupLinesVO=new FndLookupLinesVO();
                      myLineObj.headerId=myObj.headerId;
                      var token:AsyncToken=linesProxy.getByObj(myLineObj);
                      PublicFunction.addResponder(token,we_resultHandlerLines,we_faultHeadlerLines);
                  }
                 
                 
                  protected function dataHeaders_doubleClickHandler(event:MouseEvent):void
                  {
                      if (dataHeaders.selectedItem!=null){
                          var myObj:FndLookupHeadersVO=(FndLookupHeadersVO)(dataHeaders.selectedItem);
                          add=new FndHeaderDM();
                          PopUpManager.addPopUp(add,parent,true);
                          PopUpManager.bringToFront(add);
                          PopUpManager.centerPopUp(add);
                          add.init(myObj,2,myac);
                      }else{
                          Alert.show("请选定一条记录进行操作!", "信息提示");
                      }
                  }
                 
                 
                  protected function dataLines_doubleClickHandler(event:MouseEvent):void
                  {
                      if (dataHeaders.selectedItem!=null)
                      {
                          lineAdd=new FndLineDM();
                          PopUpManager.addPopUp(lineAdd,parent,true);
                          PopUpManager.bringToFront(lineAdd);
                          PopUpManager.centerPopUp(lineAdd);
                          var lineObject:FndLookupLinesVO=(FndLookupLinesVO)(dataLines.selectedItem);
                          lineAdd.init(lineObject,2,myacLines);
                      }
                      else
                      {
                          Alert.show("请选定一条记录进行操作!", "信息提示");
                      }
                  }
                 
                 
                  protected function btnAddLines_clickHandler(event:MouseEvent):void
                  {
                      if (dataHeaders.selectedItem!=null)
                      {
                          lineAdd=new FndLineDM();
                          PopUpManager.addPopUp(lineAdd,parent,true);
                          PopUpManager.bringToFront(lineAdd);
                          PopUpManager.centerPopUp(lineAdd);
                          var fndLookupLinesVO:FndLookupLinesVO=new FndLookupLinesVO();
                          var headerObject:FndLookupHeadersVO=(FndLookupHeadersVO)(dataHeaders.selectedItem);
                          fndLookupLinesVO.headerId=headerObject.headerId;
                          lineAdd.init(fndLookupLinesVO,1,myacLines);
                      }
                      else
                      {
                          Alert.show("请选定一条记录进行操作!", "信息提示");
                      }
                     
                     
                     
                     
                  }
                 
                 
                  protected function btnEditLines_clickHandler(event:MouseEvent):void
                  {
                      if (dataLines.selectedItem!=null)
                      {
                          lineAdd=new FndLineDM();
                          PopUpManager.addPopUp(lineAdd,parent,true);
                          PopUpManager.bringToFront(lineAdd);
                          PopUpManager.centerPopUp(lineAdd);
                          var lineObject:FndLookupLinesVO=(FndLookupLinesVO)(dataLines.selectedItem);
                          lineAdd.init(lineObject,2,myacLines);
                      }
                      else
                      {
                          Alert.show("请选定一条记录进行操作!", "信息提示");
                      }
                  }
                 
                  private function lineAlertClickHandler(event:CloseEvent):void { 
                      var myObj:FndLookupLinesVO=(FndLookupLinesVO)(dataLines.selectedItem);
                      if (event.detail==Alert.YES){  
                          myacLines.removeItemAt(dataLines.selectedIndex);   
                          linesProxy.removeObj(myObj);
                      }
                  }
                 
                  protected function btnDelLines_clickHandler(event:MouseEvent):void
                  {
                      if (dataLines.selectedItem!=null){
                          Alert.show("是否要删除?", "信息提示",3, this, lineAlertClickHandler);
                      }else{
                          Alert.show("请选定一条记录进行操作!", "信息提示");
                      }
                  }
                 
              ]]>
          </fx:Script>
          <s:Panel height="100%" width="100%"  title="HEADERS" autoLayout="true">
              <s:Panel x="0" y="194" height="100%" width="100%" title="LINES" autoLayout="true">
                  <mx:DataGrid x="10" y="39" height="100%" width="100%"  id="dataLines" dataProvider="{myacLines}" doubleClickEnabled="true" doubleClick="dataLines_doubleClickHandler(event)">
                      <mx:columns>
                          <mx:DataGridColumn headerText="#RowNo" labelFunction="lfRowNumLines" width="50"/>
                          <mx:DataGridColumn headerText="LINE_ID" dataField="lineId"/>
                          <mx:DataGridColumn headerText="LOOKUP_CODE" dataField="lookupCode"/>
                          <mx:DataGridColumn headerText="MEANING" dataField="meaning"/>
                          <mx:DataGridColumn headerText="DESCRIPTION" dataField="description"/>
                      </mx:columns>
                  </mx:DataGrid>
                  <s:Button x="200" y="10" label="删除" id="btnDelLines" click="btnDelLines_clickHandler(event)"/>
                  <s:Button x="10" y="10" label="追加" id="btnAddLines" click="btnAddLines_clickHandler(event)"/>
                  <s:Button x="102" y="10" label="编辑" id="btnEditLines" click="btnEditLines_clickHandler(event)"/>
              </s:Panel>
              <s:Button x="10" y="10" label="追加" id="btnAddHeader" click="btnAddHeader_clickHandler(event)"/>
              <s:Button x="106" y="10" label="编辑" id="btnEditHeader" click="btnEditHeader_clickHandler(event)"/>
              <s:Button x="207" y="10" label="删除" id="btnDelHeader" click="btnDelHeader_clickHandler(event)"/>
              <mx:DataGrid x="10" y="39" height="147" width="100%" change="dataHeaders_changeHandler(event)" doubleClick="dataHeaders_doubleClickHandler(event)" dataProvider="{myac}" id="dataHeaders" doubleClickEnabled="true" lockedColumnCount="1">
                  <mx:columns>
                      <mx:DataGridColumn headerText="#RowNo" labelFunction="lfRowNum" width="50" />
                      <mx:DataGridColumn headerText="HEADER_ID" dataField="headerId"/>
                      <mx:DataGridColumn headerText="LOOKUP_TABLE" dataField="lookupTable"/>
                      <mx:DataGridColumn headerText="LOOKUP_COLUMN" dataField="lookupColumn"/>
                      <mx:DataGridColumn headerText="LOOKUP_DESCRIPTION" dataField="lookupDescription"/>
                  </mx:columns>
              </mx:DataGrid>
          </s:Panel>
      </mx:Module>

       

      When I execute  btnAddHeader_clickHandler(event) function,error information  in the fellowing:

       

      Error: 找不到 FndHeaderDM232.SkinnableContainerSkin233.contentGroup.frm.FormItem238.txtTable 的外观。
          at spark.components.supportClasses::SkinnableComponent/attachSkin()[E:\dev\4.x\frameworks\pr ojects\spark\src\spark\components\supportClasses\SkinnableComponent.as:632]
          at spark.components.supportClasses::SkinnableComponent/validateSkinChange()[E:\dev\4.x\frame works\projects\spark\src\spark\components\supportClasses\SkinnableComponent.as:405]
          at spark.components.supportClasses::SkinnableComponent/createChildren()[E:\dev\4.x\framework s\projects\spark\src\spark\components\supportClasses\SkinnableComponent.as:368]
          at mx.core::UIComponent/initialize()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UI Component.as:7349]
          at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.x\frameworks\projects\fr amework\src\mx\core\UIComponent.as:7241]
          at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.x\frameworks\projects\fr amework\src\mx\core\Container.as:3972]
          at mx.core::Container/addChildAt()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\Cont ainer.as:2616]
          at mx.core::Container/addChild()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\Contai ner.as:2534]
          at mx.core::Container/createComponentFromDescriptor()[E:\dev\4.x\frameworks\projects\framewo rk\src\mx\core\Container.as:4392]
          at mx.core::Container/createComponentsFromDescriptors()[E:\dev\4.x\frameworks\projects\frame work\src\mx\core\Container.as:4181]
          at mx.core::Container/createChildren()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\ Container.as:3187]
          at mx.containers::FormItem/createChildren()[E:\dev\4.x\frameworks\projects\framework\src\mx\ containers\FormItem.as:479]
          at mx.core::UIComponent/initialize()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UI Component.as:7349]
          at mx.core::Container/initialize()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\Cont ainer.as:3129]
          at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.x\frameworks\projects\fr amework\src\mx\core\UIComponent.as:7241]
          at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.x\frameworks\projects\fr amework\src\mx\core\Container.as:3972]
          at mx.core::Container/addChildAt()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\Cont ainer.as:2616]
          at mx.containers::Form/addChildAt()[E:\dev\4.x\frameworks\projects\framework\src\mx\containe rs\Form.as:293]
          at mx.core::Container/addChild()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\Contai ner.as:2534]
          at mx.containers::Form/addChild()[E:\dev\4.x\frameworks\projects\framework\src\mx\containers \Form.as:282]
          at mx.core::Container/createComponentFromDescriptor()[E:\dev\4.x\frameworks\projects\framewo rk\src\mx\core\Container.as:4392]
          at mx.core::Container/createComponentsFromDescriptors()[E:\dev\4.x\frameworks\projects\frame work\src\mx\core\Container.as:4181]
          at mx.core::Container/createChildren()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\ Container.as:3187]
          at mx.core::UIComponent/initialize()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UI Component.as:7349]
          at mx.core::Container/initialize()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\Cont ainer.as:3129]
          at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.x\frameworks\projects\fr amework\src\mx\core\UIComponent.as:7241]
          at mx.core::UIComponent/addChildAt()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UI Component.as:6947]
          at spark.components::Group/addDisplayObjectToDisplayList()[E:\dev\4.x\frameworks\projects\sp ark\src\spark\components\Group.as:1825]
          at spark.components::Group/http://www.adobe.com/2006/flex/mx/internal::elementAdded()[E:\dev\4.x\frameworks\projects\ spark\src\spark\components\Group.as:1416]
          at spark.components::Group/setMXMLContent()[E:\dev\4.x\frameworks\projects\spark\src\spark\c omponents\Group.as:512]
          at spark.components::Group/set mxmlContent()[E:\dev\4.x\frameworks\projects\spark\src\spark\components\Group.as:452]
          at spark.components::SkinnableContainer/set mxmlContent()[E:\dev\4.x\frameworks\projects\spark\src\spark\components\SkinnableContaine r.as:604]
          at spark.components::SkinnableContainer/createDeferredContent()[E:\dev\4.x\frameworks\projec ts\spark\src\spark\components\SkinnableContainer.as:986]
          at spark.components::SkinnableContainer/createContentIfNeeded()[E:\dev\4.x\frameworks\projec ts\spark\src\spark\components\SkinnableContainer.as:1014]
          at spark.components::SkinnableContainer/createChildren()[E:\dev\4.x\frameworks\projects\spar k\src\spark\components\SkinnableContainer.as:827]
          at mx.core::UIComponent/initialize()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UI Component.as:7349]
          at org.mydev.fnd.view::FndHeaderDM/initialize()
          at mx.managers.systemClasses::ChildManager/childAdded()[E:\dev\4.x\frameworks\projects\frame work\src\mx\managers\systemClasses\ChildManager.as:189]
          at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::rawChildren_addChildAt()[E:\dev\4.x\frameworks \projects\framework\src\mx\managers\SystemManager.as:1963]
          at mx.managers::SystemManager/addChildAt()[E:\dev\4.x\frameworks\projects\framework\src\mx\m anagers\SystemManager.as:1595]
          at mx.managers::SystemManager/addChild()[E:\dev\4.x\frameworks\projects\framework\src\mx\man agers\SystemManager.as:1578]
          at mx.managers::PopUpManagerImpl/addPopUp()[E:\dev\4.x\frameworks\projects\framework\src\mx\ managers\PopUpManagerImpl.as:346]
          at mx.managers::PopUpManager$/addPopUp()[E:\dev\4.x\frameworks\projects\framework\src\mx\man agers\PopUpManager.as:193]
          at org.mydev.fnd.view::FndLookupDM/btnAddHeader_clickHandler()[D:\eclipse-jee-galileo-SR1-wi n32\workspace\subapp\flex_src\org\mydev\fnd\view\FndLookupDM.mxml:88]
          at org.mydev.fnd.view::FndLookupDM/__btnAddHeader_click()[D:\eclipse-jee-galileo-SR1-win32\w orkspace\subapp\flex_src\org\mydev\fnd\view\FndLookupDM.mxml:264]

       

      I hope you help me,I'm Flex new  develper. thanks!

      My Email: bh_luo@sina.com.