Patrick, tentei fazer aquilo com uma variável, mas não funcionou, segue o
código em anexo.
o erro ocorre quando clicado o botao btLimpar que chama a função
fnResetGeral() que limpa o valor de todos os campos.
valeu.
Em 10/03/08, Patrick Facchin <[EMAIL PROTECTED]> escreveu:
>
> Isso isso isso!
>
> Mas viu faz o seguinte me manda o Códe pra ver comu ta!
>
>
> Em 10/03/08, Michel Verzeletti <[EMAIL PROTECTED]<[EMAIL PROTECTED]>>
> escreveu:
> >
> > Obrigado Patrick,
> >
> >
> >
> > Mas vc poderia mandar um exemplo, não entendi como fazer. Devo colocar
> > uma função no creationComplete para inicializar as variáveis?
> >
> > Tipo:
> >
> > <mx:Canvas id="caIdentificacao" label="Identificação" y="50" width="762"
> > height="330" creationComplete="inicializaIdentificacao();">
> >
> >
> >
> > private function inicializaIdentificacao():void{
> >
> > tiEmpresa.text = "";
> >
> > }
> >
> >
> >
> > Seria alguma coisa desse tipo?
> > ------------------------------
> >
> > *De:* [email protected] [mailto:[EMAIL PROTECTED] *Em
> > nome de *Patrick Facchin
> > *Enviada em:* segunda-feira, 10 de março de 2008 11:50
> > *Para:* [email protected]
> > *Assunto:* [flexdev] Re: Como referenciar variáveis dentro de uma
> > TabNavigator?
> >
> >
> >
> > use CreationComplet nas 'TABs' para referenciar as variaveis
> >
> > Em 10/03/08, *Michel Verzeletti* <[EMAIL PROTECTED]> escreveu:
> >
> > Bom dia Galera,
> >
> > estou trabalhando em um programa que tem uma TabNavigator com 4 abas,
> > cada uma das abas possue alguns TextInputs. a aba selecionada quando a
> > página é carregada é a primeira, Fora dessa TabNavigator existe um botão
> > limpar que quando clicado, deve limpar todos os campos de todas as abas. Só
> > que ocorre o erro abaixo:
> >
> > TypeError: Error #1009: Cannot access a property or method of a null
> > object reference.
> > at manPessoa/::fnResetGeral()
> > at manPessoa/__btLimpar_click()
> >
> >
> > Percebi que se entro em todas as abas, o erro não ocorre, é como se ele
> > não encontrasse os campos quando não entramos nas abas. E isso está
> > ocorrendo sempre que referencio um campo que está em outra aba sem que eu
> > tenha entrado nela.
> > Como posso resolver esse problema?
> >
> > Obrigado a todos.
> > Att.
> > Michel
> >
> >
> >
> >
> >
> >
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
MXML:
<mx:TabNavigator id="tnPessoa" x="10" y="10" width="760" height="365"
alpha="0.95" cornerRadius="5" borderStyle="outset">
<mx:Canvas id="caIdentificacao" label="Identificação" y="50"
width="762" height="330" borderStyle="inset">
<mx:TextInput id="tiPessoa" x="75.5" y="44" width="250"
restrict="0-9" maxChars="6"/>
<mx:Label x="16.5" y="48" text="Código"/>
<mx:Label x="16.5" y="10" text="Tipo Pessoa"/>
<mx:Label id="laRazaoSocial" x="369.5" y="48"
text="Razão Social"/>
<mx:Label id="laNome" x="408.5" y="48" text="Nome"
visible="false"/>
<mx:TextInput id="tiNomeRazaoSocial" x="461.5" y="46"
width="250" maxChars="60"/>
<mx:TextInput id="tiNomeFantasia" x="75.5" y="124"
width="250" maxChars="60"/>
<mx:TextInput id="tiCnpjCpf" x="75.5" y="85"
width="250" maxChars="14" restrict="0-9"/>
<mx:TextInput id="tiInscricaoEstadual" x="461.5" y="85"
width="250" maxChars="10"/>
<mx:TextInput id="tiTelefone" x="76.5" y="165"
width="250" maxChars="11" restrict="0-9"/>
<mx:TextInput id="tiFax" x="462.5" y="167" width="250"
maxChars="11" restrict="0-9"/>
<mx:TextInput id="tiHomePage" x="461.5" y="126"
width="250" maxChars="60"/>
<mx:TextInput id="tiEndereco" x="76.5" y="207"
width="250" maxChars="60"/>
<mx:TextInput id="tiBairro" x="461.5" y="207"
width="250" maxChars="60"/>
<mx:TextInput id="tiCidade" x="76.5" y="248" width="77"
maxChars="6" restrict="0-9"/>
<mx:TextInput id="tiUf" x="658.5" y="248" width="53"
maxChars="2" editable="false"/>
<mx:TextInput id="tiCep" x="76.5" y="289" width="250"
maxChars="8" restrict="0-9"/>
<mx:TextInput id="tiCaixaPostal" x="461.5" y="289"
width="250" maxChars="10" restrict="0-9"/>
<mx:Label x="30.5" y="292" text="CEP"/>
<mx:Label x="61.5" y="44" text="*" color="#ff0000"
fontSize="20" fontFamily="Georgia" width="19" height="20"/>
<mx:Label x="447.5" y="45" text="*" color="#ff0000"
fontSize="20" fontFamily="Georgia" width="19" height="20"/>
<mx:Label x="447.5" y="86" text="*" color="#ff0000"
fontSize="20" fontFamily="Georgia" width="19" height="20"/>
<mx:Label x="62.5" y="166" text="*" color="#ff0000"
fontSize="20" fontFamily="Georgia" width="19" height="20"/>
<mx:Label x="63.5" y="206" text="*" color="#ff0000"
fontSize="20" fontFamily="Georgia" width="19" height="20"/>
<mx:Label x="447.5" y="206" text="*" color="#ff0000"
fontSize="20" fontFamily="Georgia" width="19" height="20"/>
<mx:Label x="61.5" y="86" text="*" color="#ff0000"
fontSize="20" fontFamily="Georgia" width="19" height="20"/>
<mx:Label x="631.5" y="250" text="UF"/>
<mx:Label x="17.5" y="250" text="Cidade"/>
<mx:TextInput id="tiNomeCidade" x="161.5" y="248"
width="423" maxChars="45" editable="false"/>
<mx:Label x="373.5" y="292" text="Caixa Postal"/>
<mx:Label x="6.5" y="209" text="Endereço"/>
<mx:Label x="407.5" y="207" text="Bairro"/>
<mx:Label x="382" y="128" text="Home Page"/>
<mx:Label x="420.5" y="167" text="Fax"/>
<mx:RadioButtonGroup id="rgTipoPessoa"
change="fnTrocaTipoPessoa(String(rgTipoPessoa.selectedValue))"/>
<mx:RadioButton id="rbTipoPessoaF" x="103.5" y="10"
label="Física" groupName="rgTipoPessoa" value="F"/>
<mx:RadioButton id="rbTipoPessoaJ" x="164.5" y="10"
label="Jurídica" groupName="rgTipoPessoa" selected="true" value="J"/>
<mx:Label id="laCnpj" x="28.5" y="87" text="CNPJ"/>
<mx:Label id="laCpf" x="32.5" y="87" text="CPF"
visible="false"/>
<mx:Label x="7.5" y="167" text="Telefone"/>
<mx:Label x="62.5" y="247" text="*" color="#ff0000"
fontSize="20" fontFamily="Georgia" width="19" height="20"/>
<mx:Label x="62.5" y="289" text="*" color="#ff0000"
fontSize="20" fontFamily="Georgia" width="19" height="20"/>
<mx:Button x="592.5" y="248" label="?" width="24"/>
<mx:Button x="333.5" y="44" label="?" width="24"/>
<mx:Button x="333.5" y="85" label="?" width="24"/>
<mx:Button x="719.5" y="46" label="?" width="24"/>
<mx:Button id="btBuscaInscricaoEstadual" x="718" y="85"
label="?" width="24"/>
<mx:Button id="btBuscaNomeFantasia" x="333.5" y="124"
label="?" width="24"/>
<mx:TextArea id="taNomeFantasia" x="7.5" y="119"
text="Nome
Fantasia" width="56" height="34" textAlign="center"
borderStyle="none" backgroundAlpha="0.0" editable="false"/>
<mx:TextArea id="taInscricaoEstadual" x="390.5" y="80"
text="Inscrição
Estadual" width="56" height="34" textAlign="center"
borderStyle="none" backgroundAlpha="0.0" editable="false"/>
</mx:Canvas>
<mx:Canvas id="caFiscalTributario" label="Fiscal/Tributário"
width="100%" height="100%" borderStyle="inset">
<mx:TextInput id="tiAtividade" x="245.5" y="35"
width="77" maxChars="1" restrict="0-9"/>
<mx:Label x="167.5" y="37" text="Atividade"/>
<mx:TextInput id="tiNomeAtividade" x="330.5" y="35"
width="261" editable="false"/>
<mx:TextInput id="tiOpEntrada" x="245.5" y="83"
width="77" maxChars="3" restrict="0-9"/>
<mx:Label x="100.5" y="85" text="Operação de entrada"/>
<mx:TextInput id="tiNomeOpEntrada" x="330.5" y="83"
width="261" editable="false"/>
<mx:TextInput id="tiOpSaida" x="245.5" y="130"
width="77" maxChars="3" restrict="0-9"/>
<mx:Label x="112.5" y="132" text="Operaçao de Saida"/>
<mx:TextInput id="tiNomeOpSaida" x="330.5" y="130"
width="261" editable="false"/>
<mx:Label x="231.5" y="129" text="*" color="#ff0000"
fontSize="20" fontFamily="Georgia" width="19" height="20"/>
<mx:Label x="231.5" y="82" text="*" color="#ff0000"
fontSize="20" fontFamily="Georgia" width="19" height="20"/>
<mx:Label x="231.5" y="34" text="*" color="#ff0000"
fontSize="20" fontFamily="Georgia" width="19" height="20"/>
<mx:CheckBox id="cbFunrural" x="245.5" y="181"
label="Funrural"/>
<mx:CheckBox id="cbSimplesNacional" x="245.5" y="271"
label="Simples Nacional"/>
<mx:CheckBox id="cbIssqn" x="245.5" y="229"
label="ISSQN"/>
<mx:Button x="599.5" y="35" label="?" width="24"/>
<mx:Button x="599.5" y="83" label="?" width="24"/>
<mx:Button x="599.5" y="130" label="?" width="24"/>
</mx:Canvas>
<mx:Canvas id="caFinanceiro" label="Financeiro" width="100%"
height="100%" borderStyle="inset">
<mx:TextInput id="tiNomeBanco" x="217.5" y="151"
width="421" maxChars="30"/>
<mx:TextInput id="tiMotivoInativacao" x="217.5" y="114"
width="421" maxChars="200"/>
<mx:Label x="306.5" y="82" text="Data Inativação"/>
<mx:Label x="106.5" y="116" text="Motivo Inativação"/>
<mx:TextInput id="tiNomeAgencia" x="217.5" y="189"
width="421" maxChars="30"/>
<mx:TextInput id="tiNroAgencia" x="217.5" y="225"
width="350" restrict="0-9" maxChars="10"/>
<mx:TextInput id="tiDigitoAgencia" x="575.5" y="225"
width="63" maxChars="2"/>
<mx:TextInput id="tiNroConta" x="217.5" y="261"
width="350" restrict="0-9" maxChars="10"/>
<mx:TextInput id="tiDigitoConta" x="575.5" y="261"
width="63" maxChars="2"/>
<mx:Label x="124.5" y="263" text="Número Conta"/>
<mx:Label x="107.5" y="227" text="Número Angência"/>
<mx:Label x="135.5" y="153" text="Nome Banco"/>
<mx:Label x="118.5" y="191" text="Nome Angência"/>
<mx:TextInput id="tiTipoConta" x="218.5" y="298"
width="77" maxChars="2" restrict="0-9"/>
<mx:Label x="144.5" y="300" text="Tipo Conta"/>
<mx:TextInput id="tiNomeTipoConta" x="303.5" y="298"
width="303" editable="false"/>
<mx:Button x="614.5" y="298" label="?" width="24"/>
<mx:TextInput id="tiTipoFrete" x="218.5" y="45"
width="77" maxChars="1" restrict="0-9"/>
<mx:Label x="139.5" y="47" text="Tipo Frete"/>
<mx:TextInput id="tiNomeTipoFrete" x="303.5" y="45"
width="303" editable="false"/>
<mx:Button x="614.5" y="45" label="?" width="24"/>
<mx:TextInput id="tiCondicaoPagto" x="218.5" y="10"
width="77" maxChars="3" restrict="0-9"/>
<mx:Label x="76.5" y="12" text="Condição Pagamento"/>
<mx:TextInput id="tiNomeCondicaoPagto" x="303.5" y="10"
width="303" editable="false"/>
<mx:Button x="614.5" y="10" label="?" width="24"/>
<mx:Label x="203.5" y="9" text="*" color="#ff0000"
fontSize="20" fontFamily="Georgia" width="19" height="20"/>
<mx:Label x="203.5" y="45" text="*" color="#ff0000"
fontSize="20" fontFamily="Georgia" width="19" height="20"/>
<mx:Label x="203.5" y="77" text="*" color="#ff0000"
fontSize="20" fontFamily="Georgia" width="19" height="20"/>
<mx:CheckBox id="cbAtivo" x="218.5" y="80"
label="Ativo" selected="true"/>
<mx:DateField id="dfDataInativacao" x="407.5" y="80"
width="230.5"/>
</mx:Canvas>
<mx:Canvas id="caContato" label="Contatos" width="100%"
height="334" borderStyle="inset">
<mx:DataGrid x="-1" y="49" width="930" height="260">
<mx:columns>
<mx:DataGridColumn headerText="Nome"
dataField="col1" width="200"/>
<mx:DataGridColumn headerText="Cargo"
dataField="col2"/>
<mx:DataGridColumn
headerText="Telefone" dataField="col3" width="110"/>
<mx:DataGridColumn headerText="Celular"
dataField="col4" width="110"/>
<mx:DataGridColumn headerText="E-mail"
dataField="col5"/>
<mx:DataGridColumn headerText="Data
Nascimento" dataField="col6" width="110"/>
</mx:columns>
</mx:DataGrid>
<mx:Button x="194.5" y="14" label="Adicionar Contatos"
click="caManContato.visible = true"/>
<mx:Button x="336.5" y="14" label="Editar Contato"/>
<mx:Button x="452.5" y="14" label="Excluir Contato"/>
</mx:Canvas>
</mx:TabNavigator>
<mx:ApplicationControlBar x="227.5" y="373" width="325" height="32">
<mx:Button label="Cadastrar" click="validaCamposGrava();"/>
<mx:Button label="Alterar" click="validaCamposAltera();"/>
<mx:Button label="Excluir" click="exclui.send();"/>
<mx:Button id="btLimpar" label="Limpar"
click="fnResetGeral();"/>
</mx:ApplicationControlBar>
Action Script:
private function fnResetGeral():void{
rbTipoPessoaJ.selected = true;
tiPessoa.text = "";
tiNomeRazaoSocial.text = "";
tiHomePage.text = "";
tiTelefone.text = "";
tiFax.text = "";
tiEndereco.text = "";
tiBairro.text = "";
tiCidade.text = "";
tiNomeCidade.text = "";
tiUf.text = "";
tiCep.text = "";
tiCaixaPostal.text = "";
tiAtividade.text = "";
tiNomeAtividade.text = "";
tiOpEntrada.text = "";
tiOpSaida.text = "";
cbFunrural.selected = false;
cbIssqn.selected = false;
cbSimplesNacional.selected = false;
tiCondicaoPagto.text = "";
tiNomeCondicaoPagto.text = "";
tiTipoFrete.text = "";
tiNomeTipoFrete.text = "";
cbAtivo.selected = true;
dfDataInativacao.text = "";
tiMotivoInativacao.text = "";
tiNomeBanco.text = "";
tiNomeAgencia.text = "";
tiNroAgencia.text = "";
tiDigitoAgencia.text = "";
tiNroConta.text = "";
tiDigitoConta.text = "";
tiTipoConta.text = "";
tiNomeTipoConta.text = "";
}