2 May 2011
Exercise 1.1: Setting up Flash Builder and your project files
Beginning
In this exercise you will use Flex text controls to manipulate the application as shown in Figure 1.
In this exercise, you will learn how to:
In this section, you use the Label control to add the title text to the sample application.
The Employee Portal application appears as shown in Figure 2.
You should see the Employee Portal logo appear on the stage in Design Mode.
Image control to a BitmapImage control.Note that the BitmapImage control is used here because you will not be skinning the logo.
text property a value of Employee, a fontWeight value of bold and a fontSize value of 38 (see Figure 4).
Label control and drop it next to the Employee Label control, within the HGroup container (see Figure 5).
The Employee Portal text should appear as shown in Figure 6. Note that the bottom of the text is aligned with the top of the HGroup container and not with the bottom of the logo image.
In this section, you will align text within the Label control.
Label control, assign the alignmentBaseline property value to ideographicBottom.<s:Label
fontWeight="bold" fontSize="38"
text="Employee"
alignmentBaseline="ideographicBottom" />
Label control and assign the alignmentBaseline property value to ideographicBottom.<s:Label
fontSize="38"
text="Portal"
alignmentBaseline="ideographicBottom" />
You should see the bottom of the Employee Portal text is now aligned with the bottom of the logo image (see Figure 7).
In this section, you will use a RichText control to format the Cafeteria Special Panel container's content.
calorieContent Label control.The three text primitives provided by the Spark architecture are the Label, RichText, and RichEditableText controls. The Label control only uses the Flash Text Engine (FTE) and is limited in its capabilities. It does not support rich text, scrolling, selection, or editing. This makes it the most lightweight and the fastest of these text primitives.
The RichText and RichEditableText controls support rich text with complex layout by using the Text Layout Framework (TLF) in Flash Player.
The RichText control does not support scrolling, selection, or editing, while the RichEditableText control does support these features. This makes the RichEditableText control the slowest and heaviest of the primitives, but also offers the most of what TLF can do.
Label control tags to RichText control tags. You will use the RichText control here because there is no need for a scroll bar.RichText control tags, surround the text with a span control.<s:RichText id="calorieContent"
width="220">
<s:span>
Water content...
Calorie content...
Protein content...
...
</s:span>
You should see the Calorie Information text is displayed, but it is not formatted. You will format it in the next section.
In this section, you will use the online Text Layout Editor demo to format text from the sample application.
http://labs.adobe.com/technologies/textlayout/demos/
span tags in the RichText control and paste it in the Text Layout Editor window (see Figure 8). Make sure each line of text is left aligned.
RichText tags in the Cafeteria component (see Figure 11).
Note that the <flow:span> tags are similar to the <s:span> tags in Flash Builder. The online text generation tool can be used to create all the HTML markup that can be use with Flash Builder components. However, the XML namespace component, flow must be modified to make the code function in Flash Builder.
<flow:p> tags and its contents (see Figure 12).
span tags with the Calorie text.RichText tag.<s:RichText id="calorieContent"
width="220">
<flow:p><flow:span fontSize="12" fontFamily="Arial" fontStyle="italic">Water content (grams per 100g): 47.31</flow:span></flow:p>
<flow:p><flow:span fontSize="12" fontFamily="Arial" fontStyle="italic">Calorie content of Food (kcals per 3.5oz): 283</flow:span></flow:p>
...
</s:RichText>
You should see an error occur.
The application is producing an error because the code you copied from the HTML generator contains the flow prefix within the span tags. In order for the copied code to work you must alter the namespace being used with the span; tags. You will change the flow namespace to an s to map the span element to the Spark namespace.
flow tags and calorie text.flow and replace them with an s for the Spark namespace. Set the Scope to Selected lines.You should see that all the instances of flow are replaced with s.
You should see that the calorieContent text displayed has been formatted (see Figure 14).
In this section you will use multiple properties to configure the layout of the Monthly Events Panel container.
Label control around the text to a RichEditableText control.You will use the RichEditableText control here because it supports the use of a scroll bar.
RichEditableText control, set the width to 100%.You should see the content within the MonthlyEvents component as shown in Figure 15. Note that all of the text is not displayed and there is no scroll bar. Also note that the text is editable.
RichEditableText tags with the Scroller control tag.Scroller tag, set the width and height to 100%.RichEditableText control, remove the width and height properties.You should see the content within the Monthly Events Panel container has a scroll bar on the right (see Figure 16).
RichEditableText control, assign the editable property value to false.RichEditableText tags, add an opening and closing paragraph tag before the text.<s:RichEditableText editable="false">
<s:p></s:p>
Remember that our annual company picnic...
</s:RichEditableText>
<s:p> tag, set the fontWeight property to bold.<s:p fontWeight="bold">COMPANY PICNIC</s:p>
<s:RichEditableText editable="false">
<s:p fontWeight="bold">COMPANY PICNIC</s:p>
<s:p>Remember that our annual company picnic is this ...</s:p>
<s:p>There are lots of different activities including, ...</s:p>
<s:p>As usual, due to the great response from our previous ....</s:p>
<s:p>This year's raffle is filled with wonderful prizes ...</s:p>
<s:p fontWeight="bold">FAMILY DAY AT THE BALL PARK</s:p>
<s:p>Our monthly Sales and Leadership meeting is open to ....</s:p>
<s:p>We will kick off the second part of the meeting...</s:p>
</s:RichEditableText>
RichEditableText control.You should see that the text is no longer editable within the RichEditableText control. Also note the lack of vertical spacing between the paragraph title text and the content text (see Figure 17).
RichEditableText control, assign the paragraphSpaceBefore property value to 10.The paragraphSpaceBefore property adds the defined amount of pixels before paragraph tag.
Note the spacing between the paragraph title and content (see Figure 18). Also note the padding around the scroll bar.
VerticalLayout tag under the Properties of the parent comment and paste them into the opening RichEditableText control tag.<s:RichEditableText editable="false"
paragraphSpaceBefore="10"
paddingTop="15" paddingLeft="15" paddingRight="15" paddingBottom="15">
VerticalLayout tag, delete all of the padding properties except for paddingBottom.You should see that the scroll bar is now flush with the right of the Monthly Events Panel container (see Figure 19).
In this section you will use vertical text as a label to the calorie information in the Cafeteria Special panel.
Label control for Calorie Information and the RichText control and its contents with an HGroup container.HGroup container, assign the width property a value of 100%.Label control for Calorie Information, assign the rotation property value to 270.You should see the vertical text displayed on the left side of the container as shown in Figure 20. Note that the image, title, and content are not centered.
VerticalLayout class tag within the layout object tags.VerticalLayout tag, change the paddingLeft and paddingRight properties to have value of 5.horizontalAlign property to the VerticalLayout class with a value of center.You should see that the image, title, and text are all centered within the Panel (see Figure 21).
In this exercise you used Flex text controls to manipulate an application. In the next exercise, you will use the Flash Builder Appearance view and cascading style sheets (CSS) to create the styles.
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.