Sep

26


In Flash, there is a build-in ComboBox component which acts like a dropdown popup menu in HTML. If you use it in the wrong way, you may find that the dropdown popup list appears behind the item below it. Below is an example:

this.createEmptyMovieClip("cb_grp", this.getNextHighestDepth());
cb_grp.createClassObject(mx.controls.ComboBox, "my_cb", 10);
cb_grp.my_cb.addItem({data:1, label:"One"});
cb_grp.my_cb.addItem({data:2, label:"Two"});
cb_grp.createClassObject(mx.controls.ComboBox, "my_cb2", 11);
cb_grp.my_cb2.addItem({data:1, label:"One"});
cb_grp.my_cb2.addItem({data:2, label:"Two"});
cb_grp.my_cb2._y = 30;

The reason why it happens is because Flash get confused with the keyword this, even if you change it to _root, it won’t help. There are two ways to solve this problem. First is to use a specific depth for cb_grp.
this.createEmptyMovieClip(”cb_grp”, 5);
cb_grp.createClassObject(mx.controls.ComboBox, “my_cb”, 10);
cb_grp.my_cb.addItem({data:1, label:”One”});
cb_grp.my_cb.addItem({data:2, label:”Two”});
cb_grp.createClassObject(mx.controls.ComboBox, “my_cb2″, 11);
cb_grp.my_cb2.addItem({data:1, label:”One”});
cb_grp.my_cb2.addItem({data:2, label:”Two”});
cb_grp.my_cb2._y = 30;

Another way to work around the problem is to use lockroot,

this.createEmptyMovieClip("cb_grp", this.getNextHighestDepth());
cb_grp._lockroot = true;
cb_grp.createClassObject(mx.controls.ComboBox, “my_cb”, 10);
cb_grp.my_cb.addItem({data:1, label:”One”});
cb_grp.my_cb.addItem({data:2, label:”Two”});
cb_grp.createClassObject(mx.controls.ComboBox, “my_cb2″, 11);
cb_grp.my_cb2.addItem({data:1, label:”One”});
cb_grp.my_cb2.addItem({data:2, label:”Two”});
cb_grp.my_cb2._y = 30;



Similar Posts

Comments

Name (required)

Email (required)

Website

Speak your mind

Sponsors




Links