tuf® 0 Denunciar post Postado Março 1, 2010 Boa tarde galera. Como faço para colocar o foco em um campo de texto usando AS3? No as2 era só utilizar Selection.setFocus(), mas no AS3 não faço idéia de como faz. Compartilhar este post Link para o post Compartilhar em outros sites
FabricioDezain 0 Denunciar post Postado Março 1, 2010 ta na mão ^^ var tx_1:TextField = new TextField(); tx_1.type = TextFieldType.INPUT; tx_1.width = 120; tx_1.height = 18; tx_1.x = tx_1.y = 0; tx_1.background = true tx_1.backgroundColor = 0xFF0000 addChild(tx_1); var tx_2:TextField = new TextField(); tx_2.type = TextFieldType.INPUT; tx_2.width = 120; tx_2.height = 18; tx_2.x =140; tx_2.y = 0; tx_2.background = true tx_2.backgroundColor = 0xaa00FF addChild(tx_2); tx_1.stage.focus = tx_1 function foco(evt:MouseEvent):void { //stage.focus = tx_1; //tx_1.stage.focus = tx_1 //this.stage.focus = tx_1 tx_2.stage.focus = tx_2 } stage.addEventListener(MouseEvent.CLICK, foco); http://forum.imasters.com.br/public/style_emoticons/default/joia.gif Compartilhar este post Link para o post Compartilhar em outros sites
DanielGianni 0 Denunciar post Postado Março 1, 2010 só pra complementar, a ordem de preenchimento quando vai dando tab é ajustada assim textInput1.tabIndex = 0; textInput2.tabIndex = 1; textInput3.tabIndex = 2; Fugiu do assunto mas dá um PLUS na resposta! rs Compartilhar este post Link para o post Compartilhar em outros sites
tuf® 0 Denunciar post Postado Março 1, 2010 Opa, muito obrigado, funcionou perfeitamente =] Compartilhar este post Link para o post Compartilhar em outros sites
Ohrlando 0 Denunciar post Postado Janeiro 17, 2011 não precisa acessar stage unicamente com essa referência, pode ser de qualquer lugar assim: stage.focus = object; para chamar uma função quando o texto tiver foco pode usar myTextInput.addEventListener(FocusEvent.FOCUS_IN, focusInHandler); myTextInput.addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler); function focusInHandler(event:FocusEvent):void { //Quando ganhar foco } function focusOutHandler(event:FocusEvent):void { //Quando perder o foco } http://help.adobe.com/pt_BR/AS3LCR/Flash_10.0/index.html abraço Compartilhar este post Link para o post Compartilhar em outros sites