2012-01-26 138 views
0

我想从Flex 3中的TextInput实现焦点输入/输出。我使用控制器来处理所有组件事件,我的想法是有一个switch语句根据目标“转发”到适当的方法。 我的TextInput具有id“contactInput”,但是,事件目标具有类似于“MainView0.topContainer.contactInput.UITextField8”的内容。这个UITextField8从哪里来?我不能只选择“contactInput”? 这是我的代码,在应用程序我定义的focusIn /事件的内容对所有事件:Flex 3 - 从TextInput焦点输入/输出

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
       xmlns:ui="ui.*" 
       xmlns:ws="ui.presenters.*" 
       xmlns:components="ui.components.*" 
       width="255" height="310" minWidth="255" minHeight="310" 
       creationComplete="controller.init(event)"      
       styleName="application" 
         applicationComplete="controller.init(event)" 
         focusIn="controller.focusIn(event)" 
       focusOut="controller.focusOut(event)" 

我的控制器代码:

public function focusIn(event:FocusEvent):void {     
     Alert.show("focus in -> target: " + event.target); 

     switch (event.target) { 
      case view.contactInput:    
       onContactInputFocusIn(); 
       break; 
     } 
    } 

    public function focusOut(event:Event):void { 
     Alert.show("focus out -> target: " + event.target); 

     switch (event.target) { 

      case view.contactInput: 
       onContactInputFocusOut(); 
       break;   
     } 

有什么事错在这个代码?我只是困惑。

回答

0

尝试在case和onContactInputFocusOut()函数之间放置Alert.show函数。把Alert.show放在这两个函数中,然后检查它是否出现在case语句中或不在...