Como nagegar entre telas no flex

3 respostas
C

Boa tarde
Sou iniciante em flex e estou com o seguinte problema.
Tenho uma para fazer o login e apos o login não sei como faço para fecha a tela e login e abrir a tela de cadastro de cargo.
Segue abaixo o codigo.
index.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
	layout="vertical" verticalAlign="middle" horizontalAlign="center" 
	xmlns:screen="com.digows.artigos.JavaFlex.view.screen.*">
	
	<screen:loginForm/>
</mx:Application>

loginForm.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" 
	layout="vertical" width="488" height="384" creationComplete="getList()">
	
	<mx:Form width="100%" height="100%" defaultButton="{btSalvar}">
		<mx:FormHeading label="Controle de Acesso" width="100%"/>
		<mx:FormItem label="ID:" width="127">
			<mx:TextInput width="100%" id="txtId" 
				text="{Usuario(dgCargo.selectedItem).idCargo}" editable="false" enabled="false"/>
		</mx:FormItem>
		<mx:FormItem label="Cargo:" width="345">
			<mx:TextInput width="100%" id="txtDsCargo"
				text="{Cargo(dgCargo.selectedItem).dsCargo}"/>
		</mx:FormItem>
		<mx:DataGrid id="dgCargo" width="100%" height="100%" dataProvider="{listCargos}">
			<mx:columns>
				<mx:DataGridColumn headerText="ID" dataField="idCargo" width="30"/>
				<mx:DataGridColumn headerText="Cargo" dataField="dsCargo"/>
			</mx:columns>
		</mx:DataGrid>
	</mx:Form>
	
	<mx:ControlBar horizontalAlign="center">
		<mx:Button label="Novo" click="setDefault()"/>
		<mx:Button label="Salvar" id="btSalvar" click="save()" 
			textAlign="center"/>
		<mx:Button label="Excluir" click="remove()"/>
	</mx:ControlBar>
	
	<mx:RemoteObject id="cargoService" showBusyCursor="true"
		fault="onFault(event)" destination="cargoService">
		<mx:method name="save" result="onResultSave(event)" fault="onFault(event)"/>
		<mx:method name="remove" result="onResultRemove(event)" fault="onFault(event)"/>
		<mx:method name="getList" result="onResultGetList(event)" fault="onFault(event)"/>
		<mx:method name="aviso" result="onResultGetList(event)" fault="onFault(event)"/>
	</mx:RemoteObject>
		
	<mx:Script>
		<![CDATA[
			import com.digows.artigos.JavaFlex.view.entity.Usuario;
			import mx.collections.ArrayCollection;
			import mx.rpc.events.ResultEvent;
			import mx.rpc.events.FaultEvent;
			import mx.controls.Alert;
			
			[Bindable]
			private var listCargos:ArrayCollection;
			
			private var usuario:Usuario;
			
			public function save():void
			{
				this.cargo = new Cargo();
				this.cargo.idCargo   = new Number(txtIdCargo.text);
				this.cargo.dsCargo   = txtDsCargo.text;
				
				//Chama o metodo Save do servico "cargoService"
				cargoService.save(cargo);
			}
			
			//Função que será executada após a conclusão do método save
			public function onResultSave(event:ResultEvent):void
			{
				status = "Salvo com Sucesso! Ultima ID: "+Cargo(event.result).idCargo;
				getList();
			}
			
			public function remove():void
			{
				if (dgCargo.selectedItem != null) {
					cargo = dgCargo.selectedItem as Cargo;
					cargoService.remove(cargo);
				} else {
					Alert.show("Selecione um Item na DataGrid");
				}
			}
			
			//Função que será executada após a conclusão do método remove
			public function onResultRemove(event:ResultEvent):void
			{
				status = "Excluido com Sucesso!";
				getList();
			}
			
			public function getList():void
			{
				cargoService.getList();
			}
			
			//Função que será executada após a conclusão do método getList
			public function onResultGetList(event:ResultEvent):void
			{
				listCargos = event.result as ArrayCollection;
			}
			
			public function setDefault():void
			{
				txtIdCargo.text = "";
				txtDsCargo.text = "";
			}
			
			//Ocorreu uma falha ao chamar algum servico servico.
			public function onFault(event:FaultEvent):void
			{												
				Alert.show(event.fault.message);
			}
		]]>
	</mx:Script>
</mx:TitleWindow>

valeww

3 Respostas

F

Claudemir,
Utilize a classe PopupManager para fechar a tua de login e para abrir a próxima.

Como está iniciando seus estudos e se me permite, lhe recomendo:

http://fabiophx.blogspot.com/2009/04/por-onde-comecar.html
http://fabiophx.blogspot.com/search/label/Flex%204
Recomendo tb q vá direto para o Flex4.

[]s

C

Bom dia Fabio
Eu estou utilizando o eclipse com o plugin do flex, a pergunta é o que eu preciso fazer para atualizar para a versão flex 4? tem algum plugin para essa nova versão?

T+

F

Claudemir,
Sim, tem um plugin para o Flash Builder 4, nos links q te passei tem o caminho para fazer o download.
Veja tb: http://fabiophx.blogspot.com/2010/05/instalacao-flash-builder.html

[]s

Criado 17 de maio de 2010
Ultima resposta 18 de mai. de 2010
Respostas 3
Participantes 2