I'd like to know if it's possible (AS3/Flash CS5):

  • To reset a combobox to it's prompt state when focusing (clicking) in a textinput field.

  • To empty a textinput when a value is selected in the combobox.

Thanks in advance.

UPDATE:

Many thanks Kieran. I prefer

myComboBox.selectedIndex=0;

than

myComboBox.selectedItem=myComboBox.prompt; 

Due to the index.

Is there any situation where the second one could be more useful?

有帮助吗?

解决方案

You could just add a listener for each of scenario. Something like this:

import flash.events.MouseEvent;

inputText_txt.addEventListener(MouseEvent.CLICK, clearComboBox);
comboBox.addEventListener(Event.CHANGE, clearTextBox);

function clearComboBox(event:MouseEvent):void
{
    comboBox.selectedItem = -1; 
}

function clearTextBox(e:Event):void
{
    inputText_txt.text = ""; 
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top