0 Replies Latest reply: Jul 22, 2014 2:25 PM by thetwobrothersinc RSS

    Accessing viewstack problem

    thetwobrothersinc Community Member

      Hello hope someone can help me here

       

      My problem is how can I switch my viewstack views by the userRole.

       

      Example: If admin login his userRole is Admin...I will like the viewstack (parentStack) switch to the Admin view.

       

      It works by changing the selectedIndex number ( FlexGlobals.topLevelApplication.parentStack.selectedIndex = 1; )

      But when i try selectedChild it does nothing

       

      Any help please???

       

      ------------------------------------------------------------------------------------------ ----

      XML File

      ------------------------------------------------------------------------------------------ ----

      <?xml version="1.0" encoding="UTF-8"?>

      <users>

          <user>

              <userID>admin</userID>

              <userPW>password</userPW>

              <userRole>Admin</userRole>

          </user>

          <user>

              <userID>sales</userID>

              <userPW>password</userPW>

              <userRole>Sales</userRole>

          </user>

      </users>

       

      ------------------------------------------------------------------------------------------ ----

      Custom Component Login Script

      ------------------------------------------------------------------------------------------ ----

      if (logged) {

           // Redirect user by xml role function

           FlexGlobals.topLevelApplication.parentStack.selectedIndex = 1;

           } else {

                 Alert.show('User ID or Password is not correct, please try again!', 'Error');

           }

       

      ------------------------------------------------------------------------------------------ ----

      Main Application

      ------------------------------------------------------------------------------------------ ----

      <mx:ViewStack id="parentStack" width="1280" height="768">

              <s:NavigatorContent id="loginVS" width="100%" height="100%" label="Login">

                  <forms:MainSiteForm id="mainForm" horizontalCenter="0" verticalCenter="0"/>

              </s:NavigatorContent>

              <s:NavigatorContent id="adminVS" width="100%" height="100%" label="Admin">

                  <s:ModuleLoader url="views/Administrator.swf"/>

              </s:NavigatorContent>

              <s:NavigatorContent id="salesVS" width="100%" height="100%" label="Sales">

              </s:NavigatorContent>

              <s:NavigatorContent id="designersVS" width="100%" height="100%" label="Designers">

              </s:NavigatorContent>

              <s:NavigatorContent id="retailersVS" width="100%" height="100%" label="Retailers">

              </s:NavigatorContent>

      </mx:ViewStack>