3 Replies Latest reply on Nov 13, 2009 2:27 AM by Andy Kirkham

    v2 combo in swf loaded into flex goes crazy

    epeleg
      when I have anactionscript 2 swf with a v2 combobox
      and I load it into a flex app using a swfloader
      The combo goes crazy, you click an Item and the currentItem becomes some other item that you did not click.

      has anyone encountered that ?
      does anyone have a solution ?

      thanks,
      Eyal
        • 1. Re: v2 combo in swf loaded into flex goes crazy
          ntsiii Level 3
          AS2 stuff will not work under the AS3 Virtual Machine without a lot of effort.
          Tracy
          • 2. Re: v2 combo in swf loaded into flex goes crazy
            epeleg Level 1
            this has been acknoladged as a bug by adobe
            http://bugs.adobe.com/jira/browse/SDK-13131
            • 3. Re: v2 combo in swf loaded into flex goes crazy
              Andy Kirkham

              I've just encountered this problem: two years on and it's still not fixed.

               

              If anyone's interested, what seems to be happening is that the combo's dropdown remains enabled after the user has made their selection. As the dropdown retracts, some of the subsequent menu items sweep under the mouse position and cause itemRollOver events to be fired. This changes the selectedIndex to the wrong value.

               

              On this basis I have developed the following workaround:

               

              var comboOpen:Boolean     = false;
              var currentIndex:Number    = 0;
              var indexSelected:Number     = 0

               


              theCombo.addEventListener("open",Delegate.create(this,onComboOpen));
              theCombo.addEventListener("close",Delegate.create(this,onComboClose));
              theCombo.addEventListener("itemRollOver",Delegate.create(this,onItemRollOver));
              theCombo.addEventListener("change",Delegate.create(this,onComboChange));

               

              theCombo.dropdown.onMouseDown = dropdownMouseDown;

               


              function dropdownMouseDown():Void
              {
                  // Record the item that was under the mouse
                  // when the user clicked
                  if (comboOpen)
                  {
                      indexSelected    = currentIndex;
                  }
              }

               


              function onComboOpen():Void
              {
                  comboOpen = true;
              }

               

              function onComboClose():Void
              {
                  comboOpen = false;

               

              }

               

              function onItemRollOver(e:Object):Void
              {
                  currentIndex = e.index;
              }

               


              function onComboChange():Void
              {
                  theCombo.selectedIndex = indexSelected;
                  // The combo now has the selection the user intended
              }

               

              I hope this may be of use to someone.

               

              Andy