2 Replies Latest reply on Aug 11, 2009 1:44 PM by Zolotoj

    Combobox change event fired programmatically

    Zolotoj Level 3

      according to Help this event should fire when selectedIdex property has been changed.

      This is my combobox:

      <mx:ComboBox id="portalqtags" creationComplete="portalQtags()" 

      But this:

      portalqtags.selectedIndex = newvalue;


      does not trigger the change event. What am I doing wrong?



        • 1. Re: Combobox change event fired programmatically
          Gregory Lafrance Level 6

          Not sure why this is happening, but a workaround is to manually dispatch a ListEvent.CHANGE event.


          If this post answered your question or helped, please mark it as such.


          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
               import mx.events.ListEvent;
                import mx.collections.ArrayCollection;
                [Bindable] private var ac:ArrayCollection = new ArrayCollection([
                  {qtagname: "one"}, {qtagname: "two"}, {qtagname: "three"},
                  {qtagname: "four"}, {qtagname: "five"}
                private function portalQtags():void{
                private function changeIndex(newVal:uint):void{
                  portalqtags.selectedIndex = newVal;  
                  portalqtags.dispatchEvent(new ListEvent(ListEvent.CHANGE));        
                private function clickListener():void{
            <mx:ComboBox id="portalqtags" creationComplete="portalQtags()"
              labelField="qtagname" dataProvider="{ac}"/>
              <mx:TextArea id="runtimetagname"/>
              <mx:Button label="Change Value" click="clickListener();"/>

          • 2. Re: Combobox change event fired programmatically
            Zolotoj Level 3

            Not sure if it works for me.


            here is some code:


            portalqtags.addEventListener("change", setPortalQTags)


            public function setPortalQTags(event:ListEvent):void


                 runtimetagname.text = event.target.selectedItem.qtagname;




            from another file when I issue:

            var popupWindow:TitleWindow = new TitleWindow; 

            popupWindow = c.showPopupWindow(DisplayObject(FlexGlobals.topLevelApplication), runtimeQtag);

            runtimeQtag(popupWindow).portalqtags.selectedIndex = portalqtags.selectedIndex;

            runtimeQtag(popupWindow).portalqtags.dispatchEvent(new ListEvent(ListEvent.CHANGE)); 


            I am getting:

            Cannot access a property or method of a null object reference.

            at runtimeQtag/setPortalQTags()[D:\projects\sfcs\UFDPortal\src\runtimeQtag.mxml:27


            which is:

            untimetagname.text = event.target.selectedItem.qtagname;