/** * TextFieldUtils: Clase estatica con utilidades para trabajar con campos de texto en AS3. * * * @author Ivan Gajate */ /** * Clase estatica con metodos utiles para trabajar con campos de texto. * * Copyright (C) 2009 Ivan Gajate * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * http://www.yporqueno.es * */ package es.yporqueno.utils{ import es.yporqueno.utils.ObjectUtils; import fl.text.TLFTextField; import flash.text.TextField; import flash.display.Stage; import flash.display.InteractiveObject; /** * Clase estatica con utilidades para trabajar con campos de texto en AS3. * @author Ivan Gajate | http://www.yporqueno.es * @version 1.0.0 * @see http://www.yporqueno.es */ public class TextFieldUtils{ /** * Asigna el orden de tabulacion en un array de campos que se le pasa (incluido TLFTextField) * y coloca el foco en el primero de la lista * @param field Array con los campos de texto en el orden de tabulacion que queramos. * @param st referencia al stage desde donde se asignara el foco. El foco se le asignara al primer elemento del array. * @example * * * import es.yporqueno.utils.TextFieldUtils; * import es.yporqueno.utils.ObjectUtils; * * setTabOrder([campo1, campo2, campo4, campo3], stage); * */ public static function setTabOrder(fields:Array, st:Stage):void { if (fields.length == 0) {return;} var i:uint = 1; for each (var f:Object in fields) { if (es.yporqueno.utils.ObjectUtils.getClass(f) == TLFTextField) { InteractiveObject((f as TLFTextField).getChildAt(1)).tabIndex = i; } else if (es.yporqueno.utils.ObjectUtils.getClass(f) == TextField) { InteractiveObject(f).tabIndex = i; } i++; } var firstField:Object = fields[0]; if (es.yporqueno.utils.ObjectUtils.getClass(firstField) == TLFTextField) { st.focus = InteractiveObject((firstField as TLFTextField).getChildAt(1)); } else if (es.yporqueno.utils.ObjectUtils.getClass(firstField) == TextField) { st.focus = InteractiveObject(firstField); } } } }