2 Replies Latest reply on Jul 6, 2010 4:37 AM by Kwangle

    Reselecting the Same Combo Box Item Problem

    Kwangle Level 1

      Hi All,


      I've set up a combo box that moves a large image to a specific size and position on screen when a combo box item is selected. It works fine but the image can also be moved manually by dragging and moved and scaled by pressing a 'fullscreen' button. The problem is that if I set the image to a particualr position by choosing 'Position 1' from the combo box then move and scale the image, when I choose 'Position 1' again nothing happens. This is clearly because I have set the combo box event handler to 'on (change)' and reselecting the same item doesn't count as a change to the combo box.


      How can I set the combo box so that it runs a function even if the same item is selected - I can't see any obvious event handler that activates when any item is selected in the combo box - even on(close) doesn't work because the combo box seemingly still doesn't count this as a valid selection. I can post code if you need to see something - it is very simple, but I can't get this working.


      Any ideas will be gratefully received! Thanks.

        • 1. Re: Reselecting the Same Combo Box Item Problem
          Petro O. Bochan Level 3

          import mx.utils.Delegate;

          var sel:Number = 0;

          cb.addEventListener('change', Delegate.create(this, onChange));
          cb.addEventListener('open', Delegate.create(this, onOpen));

          function onChange(event:Object):Void {

          sel = event.target.selectedIndex;
          event.target.selectedIndex = 0;

          function onOpen(event:Object):Void {
          event.target.selectedIndex = sel;

          var dp:Array = new Array();
          dp.push({label:'one', data:'one'});
          dp.push({label:'two', data:'two'});
          dp.push({label:'three', data:'three'});

          cb.dataProvider = dp;


          // cb - ComboBox component instance

          1 person found this helpful
          • 2. Re: Reselecting the Same Combo Box Item Problem
            Kwangle Level 1

            Many thanks for that, I had not encoutered the Delegate class before, but it is well worth knowing about. I did not use your code directly but some of your code pointed me in the right direction - I simply added:


            this.selectedIndex = 0;


            to the script being activated when an item in the combo box was selected. This reset the combo box to its default state with a 'Make a Selection' message, which solved my problem - having the combo box display the last item selected wasn't important for this project.


            Thanks for your help!