Então Bruno... deixei assim:
<components:NumericInput
id="idVLAQS" width="209"
text="{ tools.entidadeManipulada.vlaqs}"
change="{tools.entidadeManipulada.vlaqs = idVLAQS.value}"
textAlign="right"/>
Ocorre a mesma coisa.
Reginaldo
...sem querer ser, merecer ser um camaleão...
Em 20 de julho de 2011 09:39, bruno bg <[email protected]> escreveu:
> Reginaldo, como comentado pelo autor FABIO ,
> vc deve utiliza a propriedade VALUE e não TEXT.
> dá uma lida na parte comentada da classe.
>
>
> abraço
> brunobg
> --
> ****************************************************
> www.brbsoftware.com.br
> [email protected] (MSN & Skype)
> blogflex.brunobg.com
> @brunogrohs
> (21) 9913-2397
>
>
>
>
> Em 20 de julho de 2011 09:32, Reginaldo Ap. Rigo <
> [email protected]> escreveu:
>
>
>> Enfim posso até estar usando de maneira errada e por isso a
>>
>> questão.
>>
>> Estou usando assim:
>>
>>
>> <components:NumericInput
>>
>> id="idVLAQS" width="209"
>>
>> text="{idVLAQS.formatNumber( tools.entidadeManipulada.vlaqs )}"
>>
>> change="{tools.entidadeManipulada.vlaqs = idVLAQS.toNumber(
>> idVLAQS.text)}" textAlign="right"/>
>>
>>
>> tools.entidadeManipulada.vlaqs é minha tabela na memória e idVLAQS, claro,
>> o meu NumericInput
>>
>> Preciso formatar o texto para que apareca formatada corretamente na tela e
>>
>> preciso formatar toNumber para que o banco não reclame afinal vlaqs é um
>> campo numérico.
>>
>> Mesmo que eu tire a primeira chamada de formatação.
>>
>>
>> O que ocorre desse jeito é que não consigo digitar 0.
>>
>> Se digitar 470 por exemplo: ele "come' o zero. Se digito de novo. Ai
>> aparece e se digito de novo
>>
>> ai some inclusive o que ele já tinha assumido.
>>
>>
>> Segue abaixo o fonte do NumericInput tal como estou utilizando.
>>
>>
>> Agradeço
>>
>>
>> Reginaldo
>>
>>
>>
>>
>> package br.com.unisis.unispat.components
>>
>> {
>>
>> import flash.events.Event;
>>
>> import flash.events.FocusEvent;
>>
>> import mx.controls.TextInput;
>>
>> import mx.formatters.NumberFormatter;
>>
>> // import mx.controls.Alert;
>>
>> /**
>>
>> * Autor: Fabio da Silva
>>
>> *
>>
>> * Classe para digitação de valores, moeda ou não.
>>
>> * Característica:
>>
>> * - É utilizado o locale da aplicação para formatação
>>
>> * - A alteração dos atributos: precision, useNegativeSign e
>> useThousandsSeparator
>>
>> * e a troca de locale da aplicação em runtime provoca a reformatação do
>> valor atual.
>>
>> * - Se useNegativeSign = true e for digitado "-" em qq parte da string,
>> então o valor irá¡ ficar negativo.
>>
>> * - A alteração da propriedade text via código não provoca a sua
>> formatação
>>
>> * - IMPORTANTE: Por conveniência foi criada a propriedade value para ser
>> utilizada no lugar de text.
>>
>> * Setar text no MXML formata o valor passado, mas o mesmo não acontece qd
>> setado via código,
>>
>> * por isso, usar value.
>>
>> */
>>
>> [Event(name="valueChange", type="flash.events.Event")]
>>
>> [Event(name="propertiesNumberFormatChange", type="flash.events.Event")]
>>
>> public class NumericInput extends TextInput {
>>
>> /**
>>
>> * NumberFormatter que serão utilizados para formatar os valores deste
>> objeto.
>>
>> * Foi deixado public somente para que outros objetos possam formatar da
>> mesma maneira que este objeto.
>>
>> */
>>
>> [Bindable(event="propertiesNumberFormatChange")]
>>
>> public var nf:NumberFormatter;
>>
>> private var _precision:uint = 2;
>>
>> private var _useNegativeSign:Boolean;
>>
>> private var _useThousandsSeparator:Boolean = true;
>>
>> private var _value:Object;
>>
>> private var precisionChanged:Boolean;
>>
>> private var onlyDigits:RegExp = new RegExp("[^\\d]", "g");
>>
>> private var useNegativeSignChanged:Boolean;
>>
>> private var useThousandsSeparatorChanged:Boolean;
>>
>> public static const PROPERTIES_NUMBER_FORMAT_CHANGE:String =
>> "propertiesNumberFormatChange";
>>
>> public static const VALUE_CHANGE:String = "valueChange";
>>
>> public function NumericInput() {
>>
>> super();
>>
>> this.nf = new NumberFormatter();
>>
>> this.nf.precision = this._precision;
>>
>> this.nf.useNegativeSign = this._useNegativeSign;
>>
>> this.nf.useThousandsSeparator = this._useThousandsSeparator;
>>
>> this.addEventListener(Event.CHANGE, this.formatHandler, false, 0, true);
>>
>> this.addEventListener(FocusEvent.FOCUS_IN, this.setCursor, false, 0,
>> true);
>>
>> this.resourceManager.addEventListener(Event.CHANGE, this.formatHandler,
>> false, 0, true);
>>
>> this.maxChars = 20;
>>
>> this.restrict = "0-9";
>>
>> this.setStyle("textAlign", "right");
>>
>> this.value = 0;
>>
>> }
>>
>> override protected function updateDisplayList(unscaledWidth:Number,
>> unscaledHeight:Number):void {
>>
>> super.updateDisplayList(unscaledWidth, unscaledHeight);
>>
>> var formatChange:Boolean = (this.precisionChanged ||
>> this.useNegativeSignChanged || this.useThousandsSeparatorChanged);
>>
>> if (this.precisionChanged) {
>>
>> this.precisionChanged = false;
>>
>> this.nf.precision = this.precision;
>>
>> }
>>
>> if (this.useNegativeSignChanged) {
>>
>> this.useNegativeSignChanged = false;
>>
>> this.nf.useNegativeSign = this.useNegativeSign;
>>
>> this.restrict = (this.useNegativeSign) ? "0-9\\-" : "0-9";
>>
>> }
>>
>> if (this.useThousandsSeparatorChanged) {
>>
>> this.useThousandsSeparatorChanged = false;
>>
>> this.nf.useThousandsSeparator = this.useThousandsSeparator
>>
>> }
>>
>> if (formatChange) {
>>
>> this.value = this.text;
>>
>> this.dispatchEvent(new
>> Event(NumericInput.PROPERTIES_NUMBER_FORMAT_CHANGE));
>>
>> }
>>
>> }
>>
>> ///////////////////////////////////////////////// Propriedades
>> ////////////////////////////////////////////////
>>
>> public function get precision():uint {
>>
>> return this._precision;
>>
>> }
>>
>> /** Seta o número de casas decimais. Default = 2 */
>>
>> [Inspectable(defaultValue=2)]
>>
>> public function set precision(value:uint):void {
>>
>> if (this.precision != value) {
>>
>> this._precision = value;
>>
>> this.precisionChanged = true;
>>
>> this.invalidateDisplayList();
>>
>> }
>>
>> }
>>
>> public function get useNegativeSign():Boolean {
>>
>> return this._useNegativeSign;
>>
>> }
>>
>> /** Se permite o uso de sinal negativo. Default = false */
>>
>> [Inspectable(defaultValue=false)]
>>
>> public function set useNegativeSign(value:Boolean):void {
>>
>> if (this.useNegativeSign != value) {
>>
>> this._useNegativeSign = value;
>>
>> this.useNegativeSignChanged = true;
>>
>> this.invalidateDisplayList();
>>
>> }
>>
>> }
>>
>> public function get useThousandsSeparator():Boolean {
>>
>> return this._useThousandsSeparator;
>>
>> }
>>
>> /** Se deve usar separador de milhar. Default = true. */
>>
>> [Inspectable(defaultValue=true)]
>>
>> public function set useThousandsSeparator(value:Boolean):void {
>>
>> if (this.useThousandsSeparator != value) {
>>
>> this._useThousandsSeparator = value;
>>
>> this.useThousandsSeparatorChanged = true;
>>
>> this.invalidateDisplayList();
>>
>> }
>>
>> }
>>
>> public function get value():Object {
>>
>> return this._value;
>>
>> }
>>
>> [Bindable(event="valueChange")]
>>
>> public function set value(value:Object):void {
>>
>> nf.precision = this.precision;
>>
>> this._value = this.toNumber(value);
>>
>> this.text = this.nf.format(this._value);
>>
>> this.dispatchEvent(new Event(NumericInput.VALUE_CHANGE));
>>
>> }
>>
>> public function formatNumber(value:Object):String {
>>
>> nf.precision = this.precision;
>>
>> this._value = this.toNumber(value);
>>
>> this.text = this.nf.format(this._value);
>>
>> return this.text;
>>
>> }
>>
>> /*
>>
>> public function formataNumero(value:Object):String {
>>
>> nf.precision = this.precision;
>>
>> Alert.show("Entrada :: " + value.toString());
>>
>> this._value = this.toNumber(value);
>>
>> this.text = this.nf.format(this._value);
>>
>> Alert.show("Saida :: " + this.text);
>>
>> return this.text;
>>
>> }
>>
>> */
>>
>> /////////////////////////////////////////////////// Métodos
>> ///////////////////////////////////////////////////
>>
>> private function formatHandler(event:Event):void {
>>
>> this.value = this.text;
>>
>> this.setCursor(null);
>>
>> }
>>
>> /** Retorna uma String com sómente os digitos de value. */
>>
>> public function returnDigits(value:Object):String {
>>
>> return value.toString().replace(this.onlyDigits, "");
>>
>> }
>>
>> private function setCursor(event:FocusEvent):void {
>>
>> this.setSelection(this.length, this.length);
>>
>> }
>>
>> /**
>>
>> * Converte value.toString() para Number, se value não for Number,
>> desconsiderando
>>
>> * os caracteres q não são dígitos e respeitando as configurações.
>>
>> * Se value == null então retorna 0.
>>
>> */
>>
>> public function toNumber(value:Object):Number {
>>
>> if (value is Number) return new Number(value);
>>
>> var retorno:Number = 0;
>>
>> if (value != null) {
>>
>> retorno = Number(this.returnDigits(value));
>>
>> // Se estiver marcado q pode ser usado sinal negativo e se encontra-lo,
>> então multiplica por -1
>>
>> if (this.useNegativeSign && value.toString().indexOf("-") > -1) retorno *=
>> -1;
>>
>> }
>>
>> return (retorno / Math.pow(10, this._precision));
>>
>> }
>>
>> }
>>
>> }
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Em 20 de julho de 2011 09:19, bruno bg <[email protected]> escreveu:
>>
>> Reginaldo , tb utilizo esse componente.
>>> compartilha qual o bug, que o FABIO vendo, pode até consertar .
>>> ou até mesmo vc pode contribuir para o componente para a comunidade.
>>>
>>> o FABIO é tranquilo !!!
>>>
>>>
>>> brunobg
>>> --
>>> ****************************************************
>>> www.brbsoftware.com.br
>>> [email protected] (MSN & Skype)
>>> blogflex.brunobg.com
>>> @brunogrohs
>>> (21) 9913-2397
>>>
>>>
>>>
>>> Em 20 de julho de 2011 09:16, Reginaldo Ap. Rigo <
>>> [email protected]> escreveu:
>>>
>>> Putz... É esse mesmo que estou usando..
>>>>
>>>> Corrigi o bug das casas decimais. Mas ainda tem um outro.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Reginaldo
>>>>
>>>>
>>>> Em 20 de julho de 2011 09:07, Juliano Feltraco
>>>> <[email protected]>escreveu:
>>>>
>>>> Uso esse...
>>>>> com algumas alteracoes
>>>>>
>>>>>
>>>>> http://fabiophx.blogspot.com/2009/04/numericinput.html
>>>>>
>>>>> Em 20 de julho de 2011 09:06, Samuel Facchinello
>>>>> <[email protected]>escreveu:
>>>>>
>>>>> http://fabiophx.blogspot.com/2009/04/numericinput.html
>>>>>>
>>>>>>
>>>>>>
>>>>>> Att,
>>>>>> Samuel Facchinello
>>>>>> http://desenvolvendoemflex.blogspot.com
>>>>>> Joinville - SC
>>>>>>
>>>>>>
>>>>>>
>>>>>> Em 20 de julho de 2011 09:01, Reginaldo Ap. Rigo <
>>>>>> [email protected]> escreveu:
>>>>>>
>>>>>> Pessoal,
>>>>>>>
>>>>>>> Bom dia!
>>>>>>>
>>>>>>> Alguem de voces sabe onde posso encontrar um componente para entrada
>>>>>>> de numero no Flex bom?
>>>>>>>
>>>>>>> Tenho um aqui mas esta com um bug chato e nem tenho tempo de ver o
>>>>>>> que
>>>>>>> é no momento.
>>>>>>>
>>>>>>> Valeu.
>>>>>>>
>>>>>>> Agradeço e bom trabalho.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Reginaldo
>>>>>>>
>>>>>>> --
>>>>>>> Você recebeu esta mensagem porque está inscrito na lista "flexdev"
>>>>>>> Para enviar uma mensagem, envie um e-mail para
>>>>>>> [email protected]
>>>>>>> Para sair da lista, envie um email em branco para
>>>>>>> [email protected]
>>>>>>> Mais opções estão disponíveis em
>>>>>>> http://groups.google.com/group/flexdev
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Você recebeu esta mensagem porque está inscrito na lista "flexdev"
>>>>>> Para enviar uma mensagem, envie um e-mail para
>>>>>> [email protected]
>>>>>> Para sair da lista, envie um email em branco para
>>>>>> [email protected]
>>>>>> Mais opções estão disponíveis em
>>>>>> http://groups.google.com/group/flexdev
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Att.
>>>>> >> Juliano Feltraco <<
>>>>> 9131-6290 - 3526-9786
>>>>>
>>>>> "A vida é feita de desafios..."
>>>>>
>>>>> --
>>>>> Você recebeu esta mensagem porque está inscrito na lista "flexdev"
>>>>> Para enviar uma mensagem, envie um e-mail para
>>>>> [email protected]
>>>>> Para sair da lista, envie um email em branco para
>>>>> [email protected]
>>>>> Mais opções estão disponíveis em
>>>>> http://groups.google.com/group/flexdev
>>>>>
>>>>
>>>> --
>>>> Você recebeu esta mensagem porque está inscrito na lista "flexdev"
>>>> Para enviar uma mensagem, envie um e-mail para [email protected]
>>>> Para sair da lista, envie um email em branco para
>>>> [email protected]
>>>> Mais opções estão disponíveis em http://groups.google.com/group/flexdev
>>>>
>>>
>>>
>>>
>>> --
>>> Você recebeu esta mensagem porque está inscrito na lista "flexdev"
>>> Para enviar uma mensagem, envie um e-mail para [email protected]
>>> Para sair da lista, envie um email em branco para
>>> [email protected]
>>> Mais opções estão disponíveis em http://groups.google.com/group/flexdev
>>>
>>
>> --
>> Você recebeu esta mensagem porque está inscrito na lista "flexdev"
>> Para enviar uma mensagem, envie um e-mail para [email protected]
>> Para sair da lista, envie um email em branco para
>> [email protected]
>> Mais opções estão disponíveis em http://groups.google.com/group/flexdev
>>
>
>
>
> --
> Você recebeu esta mensagem porque está inscrito na lista "flexdev"
> Para enviar uma mensagem, envie um e-mail para [email protected]
> Para sair da lista, envie um email em branco para
> [email protected]
> Mais opções estão disponíveis em http://groups.google.com/group/flexdev
>
--
Você recebeu esta mensagem porque está inscrito na lista "flexdev"
Para enviar uma mensagem, envie um e-mail para [email protected]
Para sair da lista, envie um email em branco para
[email protected]
Mais opções estão disponíveis em http://groups.google.com/group/flexdev