_lockroot for Combo Boxes
Another fun combo box bug. This fix was in LiveDocs. But, as this blog is really the best place for me to keep track of this stuff, I’m posting it here.
I couldn’t get this to happen in a simple test, so no sample swf.
Here’s the problem…
When you open a combo box, it shows up behind other objects on stage.
The solution – set the mc that the combo is attached to’s _lockroot property to true.
I never use _lockroot (because _root is evil), but, in this case, hey, it works.
Sample code:
import mx.controls.ComboBox;
var myCombo:ComboBox;
var target:MovieClip;
var d:Number=target.getNextHighestDepth();
var params:Object={_x:30, _y:20};
target._lockroot=true;
myCombo = target.createClassObject (ComboBox, 'cb' + d + '_cb', d, params);
UPDATE August 21, 2006
Unfortunately, this does not always work. And I haven’t figured out a solution other than making sure my mcs above (lower _y values – closer to the top of the screen) have higher depths than those below (greater _y values).
Comments
One Response to “_lockroot for Combo Boxes”
Leave a Reply
You could always attach the onRollover function to swap the depth of comboBox with that of the next highest:
myCombo.onRollover = function() {
this.swapDepths(_root.getNextHighestDepth());
}