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.3: Using advanced CSS selectors

by Trilemetry

Trilemetry
  • Trilemetry, Inc.

Content

  • Use CSS descendant selectors
  • Use CSS pseudo selectors
  • Use the CSS id selector

Modified

23 May 2011

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
Flash Builder 4.7 PremiumFlexRIA
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

User level

Beginning

Required products

  • Flash Builder 4.7 Premium (Download trial)

Sample files

  • ex5_03_starter.zip
  • ex5_03_solution.zip

In this exercise you will use advanced CSS selectors to style the sample application as shown in Figure 1.

Review your tasks for this exercise.
Figure 1. Review your tasks for this exercise.

In this exercise, you will learn how to:

  • Use CSS descendant selectors
  • Use CSS pseudo selectors
  • Use the CSS id selector

Use CSS descendant selectors

In this section you will use a descendant selector to change the Button controls.

  1. Download the ex5_03_starter.zip file if you haven't already and extract the file ex5_03_starter.fxp to your computer.
  2. Open Flash Builder.
  3. Import the ex5_03_starter.fxp file.
  4. Open the ex5_03_starter.css file.
  5. Below the selector for the MonthlyEvents component, create a descendant selector for Button control instances that are located within the Panel containers.
cx|MonthlyEvents { color: #0B85B7; } s|Panel s|Button { }
  1. Within the selector, assign the color property to #000000 (black) and the chromeColor property value to #64BC48 (green).
s|Panel s|Button { color: #000000; chromeColor: #64BC48; }
  1. Save the file.
  2. Run the application.

    You should see the buttons located within the panels have a green background and black text, whereas the Logout button is unchanged (see Figure 2). The descendant selector only affected Button controls that are in Panel containers.

    The Scroller control is also a descendant of the Panel container and uses Spark Button controls in its skin for the track, thumb, up, and down buttons. As a result, any color property applied to a Spark Button control within a Panel container will also be applied to the Scroller control (see Figure 2).

See the Button controls located within the Panel containers are yellow.
Figure 2. See the Button controls located within the Panel containers are yellow.
  1. Return to the ex5_03_starter.css file in Flash Builder.
  2. Below the descendant selector for Button controls within Panel containers, create a descendant selector for the Button controls used within Scroller controls within Panel containers.
s|Panel s|Button { color: #000000; chromeColor: #64BC48; } s|Panel s|Scroller s|Button { }
  1. Within the selector, assign the chromeColor property value to #555555 (dark gray).
s|Panel s|Scroller s|Button { chromeColor: #555555; }
  1. Save the file and run the application.

The scrollbars within the panels are now dark gray (see Figure 3).

Create a descendant selector to style the Scroller controls.
Figure 3. Create a descendant selector to style the Scroller controls.

Use CSS pseudo selectors

In this section you will use pseudo selectors to change the color of Button controls based on their current state.

  1. Return to the ex5_03_starter.css file in Flash Builder.
  2. Change the Panel container descendant selector so that it applies to the down state of the Button control.
s|Panel s|Button:down { color: #000000; chromeColor: #64BC48; }
  1. Save the file and run the application.
  2. Click each button within the application and take note of the down state.

    You should see that the buttons within the panels have a green down state whereas the Logout button does not (see Figure 4).

The buttons in the panels, when clicked, are yellow.
Figure 4. The buttons in the panels, when clicked, are yellow.
  1. Return to the ex5_03_starter.css file in Flash Builder.
  2. Below the Panel container descendant selector, add a selector for the up state of the Button control and assign the color property value to #FFFFFF (white) and the chromeColor property value to #555555 (dark gray).
s|Panel s|Button:down { color: #000000; chromeColor: #64BC48; } s|Button:up { color: #FFFFFF; chromeColor: #555555; }
  1. Below the selector for the up state, add a descendant selector for the over state for the Button controls within the Panel containers and assign the color property a value of #000000 (black) and the chromeColor property value to #0D86B8 (blue).
s|Button:up { color: #FFFFFF; chromeColor: #555555; } s|Panel s|Button:over { color: #000000; chromeColor: #0D86B8; }
  1. Save the file and run the application.

You should see all the buttons in the application are a dark gray color and turn blue when the mouse is over them (see Figure 5).

Note that the scroll bar is also affected by these changes.

See the Button control over and up state color changes.
Figure 5. See the Button control over and up state color changes.
  1. Return to the ex5_03_starter.css file in Flash Builder.
  2. Locate the descendant selector for the Button control used within the Scroller control within the Panel container.
  3. Change the descendant selector so that it applies to the over state of the Button control.
s|Panel s|Scroller s|Button:over { chromeColor: #555555; }
  1. Under this instance of the descendant selector, create another descendant selector for the Button controls in the Scroller control within the Panel container and apply it to the down state of the Button control.
  2. Add the chromeColor property to the descendant selector and give it a value of #555555.
s|Panel s|Scroller s|Button:over { chromeColor: #555555; } s|Panel s|Scroller s|Button:down { chromeColor: #555555; }
  1. Save the file and run the application.

    You should see that when you mouse over or click the scroll bar, the color is now gray (see Figure 6).

The Scroller color for the down and over states is gray.
Figure 6. The Scroller color for the down and over states is gray.

Use the CSS id selector

In this section, you will use a CSS id selector to change the color of the employee name within the EmployeeOfTheMonth component.

  1. Return to Flash Builder.
  2. From the Package Explorer view, locate the components folder and open the EmployeeOfTheMonth.mxml file.
  3. Locate the Label control with the text property value assigned to ATHENA PARKER.
  4. To the Label control, add the id property with a value of employeeName.
<s:Label id="employeeName" text="ATHENA PARKER" fontWeight="bold"/>
  1. Save the file.
  2. Open ex5_03_starter.css.
  3. At the bottom of the file, use the id selector (#) and the Label control's id property value, employeeName.
#employeeName { }
  1. Within the id selector, add the color property and assign a value of #FF0000.
#employeeName { color: #FF0000; }
  1. Save the file and run the application.

    The employee name within the Employee of the Month panel is now red (see Figure 7).

The employee name is now red.
Figure 7. The employee name is now red.

In this exercise you used advanced CSS selectors to style the sample application.

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