Skip to main content
Participant
March 13, 2011
Question

problem with Cairngorm listerers

  • March 13, 2011
  • 1 reply
  • 1748 views

Hello, I have this problem.


In my application i have datagrid1, and when i click on the field i create popUp, this popUp has another datagrid2 and i can add new field to it.

My problem is this: when i click on the field datagrid1 the first (i create popUp) and add new field to datagrid2 then adding only 1 field, but if i close this popUp, and click again (i create new popUp) and add new field then adding 2 fields and etc 3-4-5....

This i show some peace of code.

Here i create popUp with datagrid2:

private function targetValueCED(e:Event):void{

                var popUp:TargetValueView=TargetValueView(PopUpManager.createPopUp(this,TargetValueView,true));

                popUp.targetOb = targetDataGrid.selectedItem as TargetVO;

                popUp.x=this.width/2 - popUp.width/2 + 40;

                popUp.y=this.height/2 - popUp.height/2;

            }

Here i create popUp for add new field:

private function newTarget():void{
                    var popUp:CreateEditValue = new CreateEditValue;
                    popUp = CreateEditValue(PopUpManager.createPopUp(this,CreateEditValue,false));
                    popUp.edit = false;
                    popUp.title = "Create new value";
                    popUp.ownerTarget = targetOb;
                    popUp.targetValueOb = new TargetValueVO();
                    popUp.x=this.parentDocument.parentDocument.width/2 - popUp.width/2;
                    popUp.y=this.parentDocument.parentDocument.height/2 - popUp.height/2;
               }

And here i dispach event:

private function saveObject():void{
     if (this.edit)
     {
     targetValueOb.data = inputName.text;
     targetValueEvent=new TargetValueEvent(TargetValueControl.EDIT_TARGET_VALUE, targetValueOb, ownerTarget);
     }
     else
     {
     targetValueOb.data = inputName.text;
     targetValueOb.targetId = ownerTarget.id;
     targetValueEvent=new TargetValueEvent(TargetValueControl.ADD_TARGET_VALUE, targetValueOb, ownerTarget);
     }
                    
     CairngormEventDispatcher.getInstance().dispatchEvent(targetValueEvent);
     close();
}

And if you need my command class:

override public function execute(event:CairngormEvent):void
          {
               var delegate : TargetValueDelegate = new TargetValueDelegate(this);
               
               try
               {
                    targetValueEvent = TargetValueEvent(event);
               }
               catch(err:Error)
               {
                    targetValueEvent=null;
               }
               
               if(targetValueEvent!=null)
               {
                    myRequest = event.type;
                    switch(event.type)
                    {
                         case TargetValueControl.LOAD_TARGET_VALUE:
                              delegate.loadTargetValue();
                              break;
                         case TargetValueControl.ADD_TARGET_VALUE:
                              delegate.addTargetValue(targetValueEvent.targetValueOb);
                              break;
                         case TargetValueControl.EDIT_TARGET_VALUE:
                              delegate.editTargetValue(targetValueEvent.targetValueOb);
                              break;
                         case TargetValueControl.REMOVE_TARGET_VALUE:
                              delegate.removeTargetValue(targetValueEvent.targetValueOb)
                    }
                    
               }
          }

Thanks for you help.

This topic has been closed for replies.

1 reply

Adobe Employee
March 14, 2011

Hi Olga,

I'm not sure to understand correctly what is the issue you are encountering with Cairngorm listeners. Could you add a sample project or screenshots so that we can have a look?

Thanks

Participant
March 14, 2011

Sorry for my post. I correct error, it was my error becouse i set controller some times.

Thanks.