23 May 2011
Exercise 1.1: Setting up Flash Builder and your project files
Beginning
In this exercise you will use Flash Builder to create the login page seen in Figure 1 and the main application page seen in Figure 2. You will create these as view states and learn how to switch between them.
In this exercise, you will learn how to:
In this section you will create an application state for the Employee Portal login page.
Note that the application is made up of a Label control, BitmapImage controls and multiple Panel containers as shown in Figure 2.
states tags.states block and paste it under the layout tags below the Properties of the parent comment.<s:states>
<s:State name="State1"/>
<s:State name="loginState"/>
</s:states>
State1 to portalState.<s:states>
<s:State name="portalState"/>
<s:State name="loginState"/>
</s:states>
You should see the portalState and loginState as shown in Figure 5.
In this section, you will configure the controls in the loginState state.
loginState from the State drop-down list (see Figure 6).
Note: You can double-click on the editor tab to expand the window to get a better view.
id property set to login and the title property set to LOGIN. Change the width property to have a value of 390, the x property to have value of 24, and the y property to have value of 95.<s:Panel id="login"
title="LOGIN"
includeIn="loginState"
x="24" y="95"
width="390" height="200">
</s:Panel>
Panel container, add a layout tag block.layout block, add a VerticalLayout class instance to arrange the layout elements in a vertical sequence.VerticalLayout instance, add the gap property set to a value of 10 to add a 10 pixel vertical gap between each element.paddingTop, paddingBottom, paddingLeft, and paddingRight properties to the VerticalLayout class and set all of their values to 15.<s:layout>
<s:VerticalLayout gap="10"
paddingTop="15" paddingBottom="15 paddingLeft="15" paddingRight="15"/>
</s:layout>
You should see the Panel container now has a title of Login as shown in Figure 8.
Label control into the Login Panel container (see Figure 9).
TextInput control and drop it in the Login Panel container under the Label control (see Figure 11)..
Label control and the TextInput control and copy them.Panel container.Notice that the Label and TextInput controls are pasted directly under the other controls (see Figure 12).
With the new Label control selected, open the Properties view and change the Text value from Username: to Password:.
The Button control should be highlighted. Note that it is nested inside the login Panel instance (see Figure 14).
login Panel container is not nested inside the caffeteriaSpecial Panel container or any other container.Remember that when you created the Login container display, you dragged and dropped it from the Components view into the Design area. If you accidentally dropped it into another container, in this step you should un-nest it.
includeIn property set to loginState.<s:Panel id="login"
title="LOGIN"
includeIn="loginState"
x="24" y="95"
width="390"
height="200">
In this section, you will remove and exclude controls from the loginState state.
loginState selected, delete the Panel containers with the following headers: Cafeteria Special, Monthly Events, Employee Directory (see Figure 15).
portalState state.You should see the controls you deleted from the loginState state still exist in the portalState state (see Figure 16).
includeIn property set to portalState.Button control with the label property set to LOGOUT.<s:Button label="LOGOUT"
x="730" y="37"
fontWeight="bold"/>
Button control, add the excludeFrom property set to the loginState state.<s:Button label="LOGOUT"
x="730" y="37"
fontWeight="bold"
excludeFrom="loginState"/>
loginState and the portalState.You should see the difference in states as shown in Figures 17 and 18.
In this section, you set the loginState state as the start state for the sample application.
loginState state and select Edit (see Figure 19).
You should see the loginState state now shows the word start in parentheses as shown in Figure 21.
currentState property has been added and set to the loginState state.<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
currentState="loginState">
login Panel container.Button control, add the click event set to change the value of the currentState property to the portalState state.<s:Button label="Submit"
click="currentState='portalState'"/>
Button control with a label property set to LOGOUT.<s:Button label="LOGOUT"
x="730" y="37"
excludeFrom="loginState"/>
Button control, add the click event set to the value of the currentState property to the loginState state.<s:Button label="LOGOUT"
x="730" y="37"
excludeFrom="loginState"
click="currentState='loginState'"/>
You should see the login state state shown in Figure 22.
You should see the application change to the portal state shown in Figure 23.
In this exercise you used Flash Builder to create the login page. In the next exercise you will learn how to lay out an application by understanding the relationship between containers and their children.
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.