Naun sabia que vc era iniciante.... Mas tem uma coisa q independe de linguagem..... A classe ViewModel pode estar em qualquer parte do projeto, vai depender da maneira como vc organizar.... Escolhi esse nome por se aproximar mais de um Model da view já que guardo seu estado atual.... Usei como um singleton porque posso acessar sua referencia facilmente de qualquer parte do projeto e a variavel é Bindable porque quando ela for atualizada automaicamente todas os componentes que referenciam ela seram atualizados de acordo com o novo valor
Nesse exemplo aih eu tenho uma classe singleton AppStates q específica os estados da aplicação.... package com.project.business.singleton { public class AppStates { private static var _instance:AppStates; public static const INICIO_STATE:String = "inicio_page"; public static const FOTOS_STATE:String = "fotos_page"; public static const VIDEOS_STATE:String = "videos_page"; public static const AMIGOS_STATE:String = "amigos_page"; public static const NOTICIA_STATE:String = "noticia_page"; public static const BIO_STATE:String = "bio_page"; public static const MEMORIA_STATE:String = "memoria_page"; public static const START_STATE:String = INICIO_STATE; [Bindable] public var appState:String = ""; public function AppStates() { } public static function instance():AppStates { if (_instance == null) { _instance = new AppStates(); } return _instance; } } } Em uma classe da View eu acesso a referencia Bindable appStates da seguinte maneira: <mx:VBox creationComplete="initPreLoader();telaAmigosPm.getOwnerData()" backgroundColor="#ffffff"* currentState="{AppStates.instance().appState}" * xmlns:mx="http://www.adobe.com/2006/mxml" width="832" height="1116" verticalGap="0" xmlns:ns1="com.commentlab.views.*" horizontalAlign="center" > <mx:states> <mx:State name="inicio_page"> <mx:SetProperty target="{iniBtn}" name="enabled" value="false"/> <mx:AddChild relativeTo="{vbox1}" position="lastChild"> <ns1:TelaInicio id="telaInicio"> </ns1:TelaInicio> </mx:AddChild> </mx:State> <mx:State name="amigos_page"> <mx:SetProperty target="{iniBtn}" name="enabled" value="true"/> <mx:SetProperty target="{amBtn}" name="enabled" value="false"/> <mx:AddChild relativeTo="{vbox1}" position="lastChild"> <ns1:TelaAmigos id="telaAmigos"> </ns1:TelaAmigos> </mx:AddChild> <mx:SetStyle target="{vbox1}" name="horizontalAlign" value="center"/> </mx:State> <mx:State name="videos_page"> <mx:SetProperty target="{videosBtn}" name="enabled" value="false"/> <mx:AddChild relativeTo="{vbox1}" position="lastChild"> <ns1:TelaVideos id="telaVideos"> </ns1:TelaVideos> </mx:AddChild> </mx:State> <mx:State name="fotos_page"> <mx:SetProperty target="{iniBtn}" name="enabled" value="true"/> <mx:SetProperty target="{fotosBtn}" name="enabled" value="false"/> <mx:AddChild relativeTo="{vbox1}" position="lastChild"> <ns1:TelaFotos id="telaFotos" height="524"> </ns1:TelaFotos> </mx:AddChild> </mx:State> <mx:State name="noticia_page"> <mx:SetProperty target="{button1}" name="enabled" value="false"/> <mx:SetProperty target="{button1}" name="buttonMode" value="true"/> <mx:AddChild relativeTo="{vbox1}" position="lastChild"> <ns1:TelaNoticia id="telaNoticia" height="834"> </ns1:TelaNoticia> </mx:AddChild> </mx:State> <mx:State name="memoria_page"> <mx:SetProperty target="{memBtn}" name="enabled" value="false"/> <mx:SetProperty target="{memBtn}" name="buttonMode" value="true"/> <mx:AddChild relativeTo="{vbox1}" position="lastChild"> <ns1:TelaMemoria id="telaMemoria"> </ns1:TelaMemoria> </mx:AddChild> </mx:State> <mx:State name="bio_page"> <mx:SetProperty target="{bioBtn}" name="enabled" value="false"/> <mx:SetProperty target="{bioBtn}" name="buttonMode" value="true"/> <mx:AddChild relativeTo="{vbox1}" position="lastChild"> <ns1:TelaBiografia id="telaBio"> </ns1:TelaBiografia> </mx:AddChild> </mx:State> </mx:states> Dessa forma em qualquer parte do projeto que eu atualizar o valor de appState tipo: *AppStates.instance().appState = AppStates.INICIO_STATE;* * * a view lá em cima que acessa a variável appState no currentState vai mudar seu estado..... ou seja , pra mudar o estado da tua tela basta uma atribuição. -- Você recebeu esta mensagem porque está inscrito na lista "flexdev" Para enviar uma mensagem, envie um e-mail para flexdev@googlegroups.com Para sair da lista, envie um email em branco para flexdev-unsubscr...@googlegroups.com Mais opções estão disponíveis em http://groups.google.com/group/flexdev