PDA

View Full Version : [AS3] dropdown box default selection


mainegate
07-15-2008, 08:53 PM
I have a dropdown box that allows me to select what webcam driver I want to select. It all works great. By default it loads the default webcam that flash knows (set in system settings). However, my dropdown menu lists all the drivers but it by default selects the first driver in the list but loads the default webcam...which is confusing.

I want it when it loads to load the default webcam like it is now but have the dropdown menu correctly display that webcam in the dropdown list.

This is what I have so far:

var my_cam:Camera = Camera.get();
var my_video:Video;
my_video.attachVideo(my_cam);
var cameras_cb:mx.controls.ComboBox;
cameras_cb.dataProvider = Camera.names;
function changeCamera():Void {
my_cam = Camera.get(cameras_cb.selectedIndex);
my_video.attachVideo(my_cam);
}
cameras_cb.addEventListener("change", changeCamera);
cameras_cb.setStyle("fontSize", 9);

Any suggestions on how to make my dropdown "select" the default camera that loads? I have tried selectItem and such but that doesn't do it.