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 mobile development tips and tricks—Part 4: Creating an alert popup and other skinnable popups

by Holly Schinsky

Holly Schinsky
  • devgirl.org

Content

  • Creating a simple alert
  • Creating a skinned popup container
  • Where to go from here

Created

24 October 2011

Page tools

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

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

 
Thanks for your feedback.

Requirements

Prerequisite knowledge

Prior experience building applications—but not necessarily mobile apps—with Flex will help you make the most of this article.

User level

Intermediate

Required products

  • Flash Builder (Download trial)

Sample files

  • flex-mobile-dev-tips-tricks-pt4.zip

This is Part 4 of a multipart series of articles that cover tips and tricks for Flex mobile development. Part 1 focused on handling data when switching between views and between application executions. Part 2 covered styling the ActionBar and tab components in your mobile application. In Part 3, you learned how to hide those components, and you saw how to move the tab components to the top of your app. This part is about a mobile alternative for the mx.controls.Alert class.

When you're developing mobile applications using Flex 4.5, you may quickly discover that you cannot use the mx.controls.Alert class. At that point, you'll likely wonder what the best practice is to display an alert or a popup message. The recommended way to display a popup window in Flex 4.5 mobile applications is via the new Spark SkinnablePopUpContainer class.

To illustrate how this class is used, I created a sample for Adobe AIR Launchpad and Tour de Flex. I also created a simple application that shows how this class can be used create an alert popup control or a more generic skinned popup container. To try this application out yourself, download and unzip the sample files for this article and import the project into Adobe Flash Builder.

Creating a simple alert

When you run the application, you'll see two tabs: Simple Alert and Skinned PopUp (see Figure 1). The first tab has a Show Alert button that instantiates an AlertMsg component when clicked.

Figure 1. The sample application's main screen (left) and simple popup alert (right).
Figure 1. The sample application's main screen (left) and simple popup alert (right).

The AlertMsg component uses a SkinnablePopUpContainer to display a basic alert message. Here's the code:

<?xml version="1.0" encoding="utf-8"?> <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark" title="SampleAlert" > <fx:Declarations> <fx:Component className="AlertMsg"> <s:SkinnablePopUpContainer x="70" y="300"> <s:TitleWindow title="My Message" close="close()"> <s:VGroup horizontalAlign="center" paddingTop="8" paddingBottom="8" paddingLeft="8" paddingRight="8" gap="5" width="100%"> <s:Label text="My alert message text here..."/> <s:Button label="OK" click="close()"/> </s:VGroup> </s:TitleWindow> </s:SkinnablePopUpContainer> </fx:Component> </fx:Declarations> <s:layout> <s:VerticalLayout paddingTop="5" paddingBottom="5" paddingLeft="5" paddingRight="5" gap="10" horizontalAlign="center" verticalAlign="top"/> </s:layout> <s:TextArea text="This sample shows how you can display a simple alert message in a mobile application using the Spark SkinnablePopUpContainer. The mx.controls.Alert is not recommended for mobile." width="98%" editable="false"/> <s:Button label="Show Alert" click="(new AlertMsg()).open(this, false)"/> </s:View>

If you set the second parameter in the open() call to true , then the alert message will be modal.

Creating a skinned popup container

The second tab in the application demonstrates a skinned popup container (see Figure 2).

Figure 2. The skinned popup view (left) and the skinned popup itself (right).
Figure 2. The skinned popup view (left) and the skinned popup itself (right).

The code for the view itself is much like the code for the previous view. The main difference is that it uses the MyPopupComponent.mxml class to facilitate the skinning:

<?xml version="1.0" encoding="utf-8"?> <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" title="SkinnablePopUpContainer" xmlns:components="components.*"> <!-- Note: This class uses the MyPopupComponent.mxml class --> <fx:Declarations> <components:MyPopupComponent id="popup"/> </fx:Declarations> <s:layout> <s:VerticalLayout paddingTop="5" paddingBottom="5" paddingLeft="5" paddingRight="5" gap="10" horizontalAlign="center" verticalAlign="top"/> </s:layout> <s:TextArea width="98%" editable="false" text="Creates a skinnable pop-up that might be used as a simple window such as an alert or help that appears as a pop-up window on top of its parent rather than within the layout and is typically defined in its' own MXML file."/> <s:Label id="txt"/> <s:HGroup> <s:Button label="Open Popup" click="popup.open(this)"/> </s:HGroup> </s:View>

Here is the code for the MyPopComponent class, which uses SkinnablePopUpContainer and the MyPopupSkin class:

<?xml version="1.0" encoding="utf-8"?> <s:SkinnablePopUpContainer xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" skinClass="skins.MyPopupSkin" x="70" y="300"> <!-- Also uses the MyPopupSkin.mxml class --> <s:VGroup paddingTop="8" paddingBottom="8" paddingLeft="8" paddingRight="8" horizontalAlign="center"> <s:Label text="My Skinned Popup Showing..."/> <s:Button label="Close" click="this.close()"/> </s:VGroup> </s:SkinnablePopUpContainer>

Finally, here are the relevant parts of the skin class itself, which rounds the top right corner and adds a drop shadow:

<!--- Defines the background and content group used by this skin. --> <s:Group id="chrome" left="0" right="0" top="0" bottom="0" visible.closedGroup="false"> <!-- Background and border - sets one corner rounded and adds a drop shadow filter--> <s:Rect left="0" right="0" top="1" bottom="0" id="background" topRightRadiusX="15"> <s:filters> <s:DropShadowFilter color="0x000000" blurX="20" /> </s:filters> <s:fill> <s:SolidColor color="0xF9F1D3"/> </s:fill> <s:stroke> <s:SolidColorStroke weight="2" color="#323232" joints="bevel" alpha=".5"/> </s:stroke> </s:Rect> <!--- @copy spark.components.SkinnableContainer#contentGroup --> <s:Group id="contentGroup" left="0" right="0" top="0" bottom="0" minWidth="0" minHeight="0"> <s:layout> <s:BasicLayout/> </s:layout> </s:Group> </s:Group>

Where to go from here

To learn more about skinning for Flex mobile applications, read Jason San Jose's series, which begins with Flex mobile skins – Part 1: Optimized skinning basics. If you haven't already done so, you may also want to read Flex mobile development tips and tricks – Part 2: Styling your application's tabs and ActionBar, which covers some ways to style your app without skinning.

Also, if you're interested in adding view transitions to your mobile app, be sure to check out Part 5 of this series.

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

  • Flex mobile skins – Part 1: Optimized skinning basics
  • Building a data-driven Flex and Java application with WebORB for Java
  • Build your first mobile Flex application – Twitter Trends
  • Mobile development using Adobe Flex 4.5 SDK and Flash Builder 4.5
  • Building a simple interaction between Flex and JavaScript using the ExternalInterface API
  • From tags to riches: Going from Web 1.0 to Flex
  • Flexible Rails excerpt: Refactoring to RubyAMF
  • Why choose Flex and PHP
  • Migrating Flex 3 applications to Flex 4 – Part 3: Introducing Spark components and simple skins
  • A Flex 3 developer's introduction to Flex 4.5 and Flash Builder 4.5

Tutorials & Samples

Tutorials

  • Flex mobile performance checklist
  • Flex and Maven with Flexmojos – Part 3: Journeyman
  • Migrating Flex 3 applications to Flex 4.5 – Part 4

Samples

  • Twitter Trends
  • Flex 4.5 reference applications
  • Mobile Trader Flex app on Android Market

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