title: Flash ComboBox component selects the wrong value in Web Browser (works fine in IDE)
body: <p>I added a standard Flash ComboBox component to my CS3 (AS2) project. It is part of one of my library symbols, not created on the stage.</p>
  
  <p>I did not make any changes to the skinning, source code, etc. of the ComboBox.</p>
  
  <p>When the user clicks on the ComboBox, the list drops down, the user uses the mouse to select an item, and that item is passed on to code that acts on it.</p>
  
  <p>In the Flash IDE, everything works fine. But when I deploy this to a WebSite and view the Flash page via a web browser, when the user clicks on the value in the drop down list, a different value is selected and shown in the type-in box.  (I am using Firefox 3.0.12 on a MAC, but our QA sees the problem in other browsers and versions). This same incorrect value is also passed to my change event callback.</p>
  
  <p>The problem is apparent for Flash Player 9 and 10.</p>
  
  <p>I tried two ways to get the value from the ComboBox.</p>
  
  <p>a) Directly accessing the component to get the selection. When using this approach, if the user uses the keyboard to choose the value OR types in the number directly, it works in IDE and Browser. Only mouse selection fails.</p>
  
  <pre><code>   var num_pages_value:Number = Number(num_pages.num_pages_cb.selectedItem["data"]);
  </code></pre>
  
  <p>b) Using an event handler. When using this approach, the keyboard access to the ComboBox stops working. Here is how I set up the event handler:</p>
  
  <p>var cb:ComboBox = num_pages.num_pages_cb;</p>
  
  <p>// Without mx.events.EventDispatcher.initialize, the change event is never fired!!!<br>
   // Not in the docs. Looked so hard to find this out...
   mx.events.EventDispatcher.initialize( cb ); 
   cb.addEventListener("change", this);</p>
  
  <p>Here is the event handler itself.</p>
  
  <p>function change(evt){
    num_pages_value = Number( evt.target.selectedItem.label );
   } </p>
  
  <p>I suspect that the call to mx.events.EventDispatcher.initialize is what breaks the keyboard interaction, but without it my handler is never called. But neither approach lets the user select the value that they want. Pick a 7 and you get 9, pick a 3 and you get 6. And the value you get is not the same each time.</p>