Tomboy77
asked on
Flex 4.5 View Stack
Hello,
I have my View stack and in view stack I have two view Login view and AdminView.
Once Click on login burron in login view in Login.mxml it will open AdminView.mxml.
I know How to do in <mx:VBox> </mx:VBox> but using <S:Group>
I don't know.
var viewStack:ViewStack = FlexGlobals.topLevelApplic ation.vs as ViewStack ;
var container:Container = Container(viewStack.getChi ldByName(v iewId));
if (container != null)
{
viewStack.selectedChild = container;
}
is working when I use Vbox instead of Sgroup.
Please let me know any solution.
Thank You
I have my View stack and in view stack I have two view Login view and AdminView.
Once Click on login burron in login view in Login.mxml it will open AdminView.mxml.
I know How to do in <mx:VBox> </mx:VBox> but using <S:Group>
I don't know.
var viewStack:ViewStack = FlexGlobals.topLevelApplic
var container:Container = Container(viewStack.getChi
if (container != null)
{
viewStack.selectedChild = container;
}
is working when I use Vbox instead of Sgroup.
Please let me know any solution.
Thank You
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" height="100%" width="100%" xmlns:view="com.us.view.*">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:ViewStack id="vs">
<s:NavigatorContent>
<view:Login id="loginViewID"/>
</s:NavigatorContent>
<s:NavigatorContent id="adminID">
<view:AdminView id="adminViewID"/>
</s:NavigatorContent>
</mx:ViewStack>
</s:Application>
//Login.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import com.us.controller.ViewController;
import mx.core.Container;
import mx.containers.ViewStack;
import mx.controls.Alert;
import mx.controls.DataGrid;
import mx.core.FlexGlobals;
import spark.components.Application;
public function checkLogin(event:Event,viewId:String):void{
if((username.text=="admin") && ( password.text=="password")){
trace("Loged")
var viewStack:ViewStack = FlexGlobals.topLevelApplication.vs as ViewStack ;
var container:Container = Container(viewStack.getChildByName(viewId));
if (container != null)
{
viewStack.selectedChild = container;
}
username.text = "";
password.text = "";
}
else{
Alert.show("Entered incorrect username or password");
}
}
]]>
</fx:Script>
<s:BorderContainer >
<s:layout>
<s:VerticalLayout horizontalAlign="center" verticalAlign="middle" />
</s:layout>
<s:Label text="Login" fontSize="15" fontWeight="bold" />
<mx:Form id="form" >
<mx:FormItem label="User name:">
<s:TextInput id="username"/>
</mx:FormItem>
<mx:FormItem label="Password:">
<s:TextInput id="password" displayAsPassword="true"/>
</mx:FormItem>
<mx:FormItem>
<s:Button id="button1" label="Log In" click="checkLogin(event,'adminViewID')"/>
</mx:FormItem>
</mx:Form>
</s:BorderContainer >
</s:Group>
//Admin View
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
height="100%" width="100%">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Label text="Admin View"/>
</s:Group>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Appreciate it.
it's all set
it's all set
<mx:ViewStack id="vs">
<view:Login id="loginViewID"/>
<view:AdminView id="adminViewID"/>
</mx:ViewStack>