package { import flash.display.Sprite; import flash.text.TextField; import flash.text.TextFieldType; import flash.events.FocusEvent; public class Main extends Sprite { private var _field1:TextField = new TextField( ); private var _field2:TextField = new TextField( ); public function Main( ) { _field1.border = true; _field1.background = true; _field1.type = TextFieldType.INPUT; addChild(_field1); _field1.addEventListener(FocusEvent.KEY_FOCUS_CHANGE, onKeyFocus); _field2.border = true; _field2.background = true; _field2.type = TextFieldType.INPUT; addChild(_field2); _field2.y = 100; } private function onKeyFocus(event:FocusEvent):void { if(_field1.text == "") { event.preventDefault( ); } } }}
Name (required)
email (will not be published) (required)
Website