Adobe
Products

Top destinations

  • Adobe Creative Cloud
  • Creative Suite
  • Adobe Marketing Cloud
  • Acrobat
  • Photoshop
  • SiteCatalyst
  • Students
  • Elements family

Adobe Creative Cloud

  • What is Adobe Creative Cloud?
  • Design
  • Web
  • Photography
  • Video
  • Students
  • Teams
  • Enterprise
  • Educational institutions

Design and photography

  • Photoshop
  • Illustrator
  • InDesign
  • Adobe Muse
  • Lightroom

Video

  • Adobe Premiere
  • After Effects

Web development and HTML5

  • Edge Tools & Services [opens in a new window]
  • Dreamweaver
  • Gaming [opens in a new window]

Adobe Marketing Cloud

  • What is Adobe Marketing Cloud?
  • Digital analytics
  • Social marketing
  • Web experience management
  • Testing and targeting
  • Media optimization

Analytics

  • SiteCatalyst
  • Adobe Discover
  • Insight

Social

  • Adobe Social

Experience Manager

  • CQ
  • Scene7

Target

  • Test&Target
  • Recommendations
  • Search&Promote

Media Optimizer

  • AdLens
  • AudienceManager
  • AudienceResearch

Document services

  • Acrobat
  • EchoSign [opens in a new window]
  • FormsCentral [opens in a new window]
  • SendNow [opens in a new window]
  • Acrobat.com [opens in a new window]

Publishing

  • Digital Publishing Suite

  • See all products
Business solutions

By business need

  • Digital analytics
  • Digital publishing
  • Document management
  • Media optimization
  • Social marketing
  • Testing and targeting
  • Video editing and serving
  • Web development [opens in a new window]
  • Web experience management
  • See all business needs

By industry

  • Broadcast
  • Education
  • Financial services
  • Government
  • Publishing
  • Retail
  • See all industries
Support & Learning

I need help

  • Products
  • Adobe Creative Cloud
  • Adobe Marketing Cloud
  • Forums [opens in a new window]

I want to learn

  • Training and tutorials
  • Certification [opens in a new window]
  • Adobe Developer Connection
  • Adobe Design Center
  • Adobe TV [opens in a new window]
  • Adobe Marketing Center
  • Adobe Labs [opens in a new window]
Download
  • Product trials
  • Adobe Flash Player
  • Adobe Reader
  • Adobe AIR
  • See all downloads
Company
  • Careers at Adobe
  • Investor Relations
  • Newsroom
  • Privacy
  • Corporate Social Responsibility
  • Customer Showcase
  • Contact us
  • More company info
Buy
  • For personal and professional use
  • For students, educators, and staff
  • For small and medium businesses
  • Volume Licensing
  • Special offers
  • Adobe Marketing Cloud sales [opens in a new window]
Search
 
Info Sign in
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Welcome,
My Adobe
My orders
My information
My preferences
My products and services
Sign out
My cart
Privacy My Adobe
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out Privacy My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Promotions
Estimated shipping
Tax
Calculated at checkout
Total
Review and Checkout
Adobe Developer Connection / Flex Developer Center / Flex in a Week /

Exercise 5.6: Creating custom skin properties

by Trilemetry

Trilemetry
  • Trilemetry, Inc.

Content

  • Create a custom skin property
  • Pass a value to a custom skin property

Modified

23 May 2011

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
Flash BuilderFlexRIA
Was this helpful?
Yes   No

By clicking Submit, you accept the Adobe Terms of Use.

 
Thanks for your feedback.

Requirements

Prerequisite knowledge

  • Exercise 1.1: Setting up Flash Builder and your project files
  • Exercise 5.1: Using text controls
  • Exercise 5.2: Defining selector styles
  • Exercise 5.3: Using advanced CSS selectors
  • Exercise 5.5:Creating and applying skins

User level

Beginning

Required products

  • Flash Builder 4.7 Premium (Download trial)

Sample files

  • ex5_06_starter.zip
  • ex5_06_solution.zip

In this exercise you will create a custom skin property and reuse it to style a Panel container skin with differently colored highlights (see Figure 1).

This is the finished application.
Figure 1. Review your task for this exercise.

In this exercise, you will learn how to:

  • Create a custom skin property
  • Pass a value to a custom skin property

Create a custom skin property

In this section, you will change the color of the title bar for each of the Panel containers within the Employee Portal application.

  1. Download the ex5_06_starter.zip file if you haven't done so already and extract the ex5_06_starter.fxp file to your computer.
  2. Open Flash Builder.
  3. Import the ex5_06_starter.fxp file.
  4. Open the ex5_06_starter.mxml file.
  5. Locate the four panel instances in the components namespace and comment them out.
  6. Save the file.
  7. In the Package Explorer, right-click the components package and select New > MXML Component.
  8. Name the MXML component EmployeePortalPanel.
  9. Click the Browse button next to the Based on field.
  10. In the Based on dialog box, type Panel and select the Spark Panel container (see Figure 2).
Base the new MXML component on the Spark Panel container.
Figure 2. Base the new MXML component on the Spark Panel container.
  1. Click OK.
  2. In the New MXML Component dialog box, type 250 for the Width value and 475 for the Height value (see Figure 3).
Name the component EmployeePortalPanel, base it on the Spark Panel container, and replace the Width and Height values.
Figure 3. Name the component EmployeePortalPanel, base it on the Spark Panel container, and replace the Width and Height values.
  1. Click Finish.

    The EmployePortalPanel.mxml file will open in the Flash Builder Editor view.

  2. Delete the Declaration tag block and create a Script block.
  3. Within the Script block, type panelTitleColor and press CTRL+1 to invoke the quick assist tool. Select the Create instance variable option. This will create a private variable named panelTitleColor data typed to the Object class.
  4. Change the variable's access modifier to public and modify the data type to the uint class.
<fx:Script> <![CDATA[ public var panelTitleColor:uint; ]]> </fx:Script>
  1. Save the file.
  2. Open the ex5_06_starter.mxml file.
  3. After the four Panel instances that you commented out, create an EmployeePortalPanel component tag block.
  4. To the EmployeePortalPanel component opening tag, assign the title property value to EMPLOYEE OF THE MONTH.
  5. Use the content assist tool to add the panelTitleColor property to the EmployeePortalPanel tag and give it a value of #64BC48 (green).
  6. Within the EmployeePortalPanel component tag set, add an instance of the EmployeeOfTheMonth component.
<components:EmployeePortalPanel title="EMPLOYEE OF THE MONTH" panelTitleColor="#64BC48"> <components:EmployeeOfTheMonth/> </components:EmployeePortalPanel>
  1. Save the file and run the application.

    You will see only one panel that is not properly positioned. You will fix that later. However, note that there are two panel title areas for the Employee of the Month panel (see Figure 4). This occurs because each component is based on the Panel container.

There are two panels for the Employee of the Month panel.
Figure 4. There are two panels for the Employee of the Month panel.
  1. Return to Flash Builder and open the EmployeeOfTheMonth.mxml component.
  2. Change the component's Panel container to a Group container.
  3. In the opening Group container tag, reassign the width and height properties to a value of 100%.
<s:Group xmlns:fx=http://ns.adobe.com/mxml/2009 xmlns:s="library://ns.adobe.com/flex/spark" width="100%" height="100%">
  1. Save the file.
  2. Repeat steps 23-26 for the Cafeteria.mxml and MonthlyEvents.mxml components.
  3. Return to the ex5_06_starter file.
  4. From the commented EmployeeOfTheMonth component instance, copy the x, y, and skinClass properties and their values and paste them into the opening EmployeePortalPanel component instance.
  5. To the opening EmployeePortalPanel component instance, add the height property with a value of 295.
<components:EmployeePortalPanel title="EMPLOYEE OF THE MONTH" panelTitleColor="#64BC48" x="0" y="95" skinClass="skins.PanelContainerSkin" height="295">
  1. Save the file and run the application.

    You should see that only the Employee of the Month panel is displayed and the color block of the panel's title bar has not changed (see Figure 5).

Only the Employee of the Month panel is displayed.
Figure 5. Only the Employee of the Month panel is displayed.

Pass a value to a custom skin property

In this section you will create a function to handle the passing of the panelTitleColor property value from the main application file to the custom component.

  1. Return to Flash Builder and open the PanelContainerSkin.mxml file from the skins package.
  2. Locate the nested fill property within the Rect tag block that follows the PanelSkin instance.
  3. From the nested SolidColor tag, remove the color property value:
<s:fill> <s:SolidColor/> </s:fill>
  1. To the SolidColor tag, assign the id property to headerSkinColor:
<s:fill> <s:SolidColor id="headerSkinColor"/> </s:fill>
  1. Locate the MetaData tags.
  2. Within the HostComponent() function, change the value to reference the EmployeePortalPanel component:
<fx:Metadata> [HostComponent("components.EmployeePortalPanel")] </fx:Metadata>
  1. Locate the Script comment and add a Script block below it:
<!-- Script ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> <fx:Script> <![CDATA[ ]]> </fx:Script> ...
  1. Within the Script block, create a private function named initTitleSkin that returns a void data type:
<fx:Script> <![CDATA[ private function initTitleSkin():void { } ]]> </fx:Script>
  1. Within the initTitleSkin() function, assign the color property of the headerSkinColor SolidColor fill to the hostComponent.panelTitleColor property value:
private function initTitleSkin():void { headerSkinColor.color = hostComponent.panelTitleColor; }
  1. To the opening SparkSkin tag, assign the creationComplete property value to call the initTitleSkin() function:
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark" creationComplete="initTitleSkin()">
  1. Save the file and run the application.

    You should see that the color block in the Employee of the Month panel is now green (see Figure 6).

Change the Employee of the Month Panel container's header color block to green.
Figure 6. Change the Employee of the Month Panel container's header color block to green.
  1. Return to the ex5_06_starter.mxml file in Flash Builder.
  2. Copy the EmployeePortalPanel component and paste two instances below the first.
<components:EmployeePortalPanel title="EMPLOYEE OF THE MONTH" panelTitleColor="#64BC48" x="0" y="95" skinClass="skins.PanelContainerSkin" height="295"> <components:EmployeeOfTheMonth/> </components:EmployeePortalPanel> <components:EmployeePortalPanel title="EMPLOYEE OF THE MONTH" panelTitleColor="#64BC48" x="0" y="95" skinClass="skins.PanelContainerSkin" height="295"> <components:EmployeeOfTheMonth/> </components:EmployeePortalPanel> <components:EmployeePortalPanel title="EMPLOYEE OF THE MONTH" panelTitleColor="#64BC48" x="0" y="95" skinClass="skins.PanelContainerSkin" height="295"> <components:EmployeeOfTheMonth/> </components:EmployeePortalPanel>
  1. To the second instance of the EmployeePortalPanel component, reassign the title property to CAFETERIA SPECIAL, the panelTitleColor property value to #F05123 (orange), and the x property value to 275.
  2. Remove the height property and and change the nested component to the Cafeteria component.
<components:EmployeePortalPanel title="CAFETERIA SPECIAL" panelTitleColor="#F05123" x="275" y="95" skinClass="skins.PanelContainerSkin"> <components:Cafeteria/> </components:EmployeePortalPanel>
  1. To the third instance of the EmployeePortalPanel component, reassign the title property to MONTHLY EVENTS, the panelTitleColor property value to #0D86B8 (blue), and the x property value to 550.
  2. Remove the height property and change the nested component to the MonthlyEvents component.
<components:EmployeePortalPanel title="MONTHLY EVENTS" panelTitleColor="#0D86B8" x="550" y="95" skinClass="skins.PanelContainerSkin"> <components:MonthlyEvents/> </components:EmployeePortalPanel>
  1. Locate the commented EmployeeDirectory component instance.
  2. Copy the EmployeeDirectory component instance and paste it below the third instance of the EmployeePortalPanel component.

    Since the EmployeeDirectory component does not use the PanelContainerSkin, you do not need to nest it within an EmployeePortalPanel component instance.

  3. Save the file and run the application.

    You should see the Employee of the Month, Cafeteria Special, and MonthlyEvents panels have different colored headers (see Figure 7). Also note that the text in the Monthly Events panel is blue.

Pass the EmployeePortalPanel component the header color from the main application.
Figure 7. Pass the EmployeePortalPanel component the header color from the main application.
  1. Return to Flash Builder and open the ex5_06_starter.css file.
  2. Locate the MonthlyEvents selector and comment out the color property.
  3. Save the file and run the application.

You should see that the text within the Monthly Events panel is now black (see Figure 8).

The text in the Monthly Events panel is black.
Figure 8. The text in the Monthly Events panel is black.

In this exercise you created a custom skin property and reused it to style a Panel container skin with different colored highlights. In the next exercise you will learn how to use a skin to make the Panel container title bar vertical.

Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License+Adobe Commercial Rights

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.

More Like This

  • Exercise 5.10: Creating a production build
  • Exercise 5.8: Animating Button components
  • Exercise 3.4: Passing data to the server with the WebService class
  • Exercise 3.7: Using two-way binding
  • Exercise 2.8: Creating an ArrayCollection of value objects
  • Exercise 3.4: Passing data to the server with the RemoteObject class
  • Exercise 3.6: Validating form data
  • Exercise 4.4: Using the Spark DataGrid control
  • Exercise 4.6: Navigating using navigator containers
  • Exercise 5.1: Using text controls

Products

  • Adobe Creative Cloud
  • Creative Suite
  • Adobe Marketing Cloud
  • Acrobat
  • Photoshop
  • Digital Publishing Suite
  • Elements family
  • SiteCatalyst
  • For education

Download

  • Product trials
  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR

Support & Learning

  • Product help
  • Forums

Buy

  • For personal and professional use
  • For students, educators, and staff
  • For small and medium businesses
  • Volume Licensing
  • Special offers

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2013 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

Ad Choices

Reviewed by TRUSTe: site privacy statement