android - How to alter the active text field in AS3? -


i have 6 text fields on stage along keypad numbers 0-9.

ultimately going android app. , want able select text field , press keypad buttons , have numbers appear in active text field.

i've been trying google active field , similar searches , can't seem find reference.

keep in mind i'm fumbling around in dark i've tried gather multiple tutorials. code complete garbage:

package  {  public class main {      import flash.display.movieclip;     import flash.events.mouseevent;     import fl.managers.focusmanager;     var focus:focusmanager = new focusmanager(this);      btn_1.addeventlistener(mouseevent.mouse_down, inputnumber);      public function inputnumber(m:mouseevent){             focus.text = 1;     }      public function main() {         // constructor code     }  }  } 

current errors:

c:\users\otaku\documents\lottocount\main.as, line 19, column 35 1118: implicit coercion of value static type flash.display:interactiveobject possibly unrelated type flash.text:textfield.  c:\users\otaku\documents\lottocount\main.as, line 14, column 44 1120: access of undefined property onmybuttonclick.  c:\users\otaku\documents\lottocount\main.as, line 14, column 3  1120: access of undefined property btn_1.  c:\users\otaku\documents\lottocount\main.as, line 13, column 47 1120: access of undefined property onfocusin.  c:\users\otaku\documents\lottocount\main.as, line 13, column 3  1120: access of undefined property stage. 

if access focus object, you'll have reference active (focused on) object.

but in reality, having textfield allows input open keyboard view (only on mobile) on touching it.

you can tell flash not automatically show keyboard, if plan use own, can use focus or make own system track appropriate textfield depending on last touch was.

edit:

here's simplistic example of how done.
in example have 2 textfields: tf1 , tf2. i've added button sake of covering situation need save last focus on concrete type of object. buttons name mybutton.

var lastselectedtextfield:textfield; // hold our last selected textfield  // make sure stage exists. if you're writing script in frame, don't mind, if use oop approach can adding eventlistener event added_to_stage  stage.addeventlistener(focusevent.focus_in, onfocusin); // onfocusin trigger every time focus changed. mybutton.addeventlistener(mouseevent.click, onmybuttonclick);  function onfocusin(e:focusevent):void {     if (stage.focus textfield)            lastselectedtextfield = stage.focus textfield; }  function onmybuttonclick(e:mouseevent):void {     trace("text of last selected text field is:", lastselectedtextfield.text); } 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -