jeudi 19 janvier 2017

Flex4 - Use ButtonBar to navigate from one .mxml file to another

I am creating a Windowed Application in Flex3 with Adobe Flash Builder 4.7

I have two .mxml files (Main.mxml and Home.mxml)

In Main.mxml I have ButtonBar, when the user clicks on the Home ButtonBar, I want the user to be redirected to Home.mxml

I have been googling this for awhile now and there is no clear answer on this.

I have looked into ViewStack and TabNavigator and States, I am not sure if that is what I am looking for.

Here is my Main.mxml File

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ift.tt/rYUnH9" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                       applicationComplete="init()"
                       showStatusBar="false">

    <fx:Declarations></fx:Declarations> 

    <fx:Style>
        @namespace s "library://ns.adobe.com/flex/spark";
        s|ButtonBar s|ButtonBarButton:upAndSelected,
        s|ButtonBar s|ButtonBarButton:overAndSelected,
        s|ButtonBar s|ButtonBarButton:downAndSelected,
        s|ButtonBar s|ButtonBarButton:disabledAndSelected {
            chromeColor: #666666;
            color: #FFFFFF;
            fontSize: 32;
        }
        s|ButtonBar { 
            chromeColor: #000000;
            color: #FFFFFF;
            fontSize: 32;
            bottom: 0;
            typographicCase: uppercase;
        }
    </fx:Style>

    <s:ButtonBar width="100%" height="13%">  
        <mx:ArrayCollection>
            <fx:String>Home</fx:String>
        </mx:ArrayCollection>
    </s:ButtonBar>

</s:WindowedApplication>

and here is my Home.mxml file

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ift.tt/rYUnH9" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <s:Label text="Here"/>

</s:WindowedApplication>

Please Help

Aucun commentaire:

Enregistrer un commentaire