Adobe
製品
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
その他の製品一覧
ソリューション
デジタルマーケティング
デジタルメディア
教育
金融機関
Web Experience Management
その他のソリューション
ラーニング サポート ダウンロード 会社情報
ご購入
アドビストア 安心のサポート& サービス
アカデミックストア 学生、教職員、個人向け
アドビライセンスストア 中小企業向け
ボリュームライセンスについて 企業、教育機関、官公庁向け
販売パートナー
キャンペーン情報
検索
 
情報 サインイン
ようこそ、 さん カート 注文状況 マイアカウント
マイアカウント
注文状況
アカウント情報の変更
コミュニケーションの設定を変更
サインアウト
サインインの目的 お客様のアカウントや体験版ダウンロード、製品の拡張機能、コミュニティエリアへのアクセスなどを管理するため
Adobe
製品 セクション ご購入   検索  
ソリューション 会社情報
サポート ラーニング
サインイン サインアウト 注文状況 マイアカウント
先行予約の提供開始予定日Date. 商品が発送されるまで、クレジットカードには課金されません。提供開始の予定日は変更される場合があります。 先行予約の提供開始予定日Date. ダウンロードの準備が整うまで、クレジットカードには課金されません。提供開始の予定日は変更される場合があります。
個数:
ご購入には学生・教職員個人版の購入資格の確認が必要です。
小計
カートの中身を見る
Adobe Developer Connection / Flexデベロッパーセンター /

Layout mirroring with Flex

著者 Michaël Chaize

Michaël Chaize
  • Adobe

Content

  • Three mirroring examples
  • Implementing mirroring
  • Tips for using layout mirroring
  • Where to go from here

Created

17 January 2011

ページ ツール

Facebookでシェア
Twitterでツイート
LinkedInでシェア
ブックマーク
印刷

タグ

必要条件

この記事に必要な予備知識

Familiarity with ActionScript and MXML is required.

ユーザーレベル

中級

必要な製品

  • Flash Builder 4 (Download trial)
  • Flex 4.1 SDK

サンプルファイル

  • flex-layout-mirroring.zip

When Adobe officially launched Flex 4.1 many developers were excited by a major new feature: layout mirroring. Some countries use right-to-left languages such as Arabic or Hebrew, which means that many Flex developers need to support right-to-left (RTL) locales. What you may not realize about RTL is that it targets not only text fields, but the whole user interface. Acrobat 8, for example, was localized in Arabic by Winsoft. Within the application, the entire UI is mirrored, including menus, lists, combo-boxes, and labels (see Figure 1). The vertical scroll bars appear on the left instead of the right, and with horizontal scrollbars, the thumb starts on the right side of the control instead of the left.

Adobe Acrobat Professional localized in Arabic.
Figure 1. Adobe Acrobat Professional localized in Arabic.

To support layout mirroring, new APIs have been added including the layoutDirection style property, which supports layout mirroring and the direction style property, which controls text direction in text controls. To change your application's layout from left-to-right (LTR) to RTL, simply set the layoutDirection property to "rtl" . It's the easiest way to work with RTL interfaces. This new property can also be set on any UIComponent, GraphicElement, SpriteVisualElement, or UIMovieClip object. This new API works with MX and Spark components.

For text in text components, you'll need to use the Flash Text Engine (FTE) introduced in Flash Player 10. Set the direction property to "rtl" on text components to reverse the default direction.

Three mirroring examples

I developed some samples for Tour de Flex to illustrate these new capabilities. To access these samples, download and install the Tour de Flex application, and explore Flex 4 > Coding Techniques > Layout Mirroring.

The first sample lets you play with the two new properties: layoutDirection for layout controls, and direction for text controls. Even advanced components, such as charting controls, are supported. If you try out the sample, you'll notice that the characters themselves are not rendered from right to left. This is because they use an LTR-based character set.

Note: The samples modify the layout of the panel in, not the Application tag.

Flash playerがありません Flash 10が必要ですか? Flash 10が必要ですか?

The second sample demonstrates how the new mirroring API works with all coordinates. To see this in action, draw something in the panel below and toggle the layout direction; your drawing will be mirrored:

Flash playerがありません Flash 10が必要ですか? Flash 10が必要ですか?

The third sample illustrates mirroring text in a text input control:

Flash playerがありません Flash 10が必要ですか? Flash 10が必要ですか?

Implementing mirroring

As you can see in the examples above, the two new direction properties in Flex 4.1 make it easy to modify the direction of your application's layout controls, text controls, or both. The layoutDirection property deals strictly with layout mirroring, or how the containers and controls are drawn on the screen. By default, this property is set to "ltr" (left to right), but you can change this value at runtime to "rtl" (right to left). The easiest way is to set this property at the Application level (in the MXML Application tag) because all the containers and controls will inherit its value. You can use either MXML or ActionScript to set this property.

For example, in MXML, you can use the following:

<s:MyContainer id="myContainer" layoutDirection="rtl"/>

Alternatively, you can use setStyle() in ActionScript:

myContainer.setStyle("layoutDirection", "rtl");

You can also use CSS to set the layoutDirection property on your components:

s|Panel { layoutDirection: rtl; }

The direction property controls the direction in which text is rendered in text-based controls. Typically, you'd use the direction property on the Application tag or the parent container of your text controls. Remember that the direction style is built into Spark text components, because those text controls use the new Flash Text Engine. To use this text engine with MX controls you'll need to adjust your compiler settings; for example:

mxmlc -theme+=themes/MXFTEText.css MyApp.mxml

When you use the theme compiler option to specify the MXFTEText.css theme file, the compiler replaces mx.core.UITextField components with mx.core.UIFTETextField components, which support FTE and layout mirroring on text.

Tips for using layout mirroring

When possible, set the layoutDirection and direction properties directly on the Application container. Avoid using absolute positioning and be careful with mirroring images. If you plan to mirror the contents of images (or videos), you should reverse your graphical assets in your image editing tool prior to importing them into your Flex application. Also, note that the Image, BitmapImage, and VideoPlayer controls don't inherit the layoutDirection property from their parent container. Lastly, be aware that in many components, navigation with the arrow keys changes depending on the direction of the text. Always test your components with the arrow keys.

Where to go from here

Now that you know how easy it is to add layout mirroring behavior to your Flex application, I encourage you to download and install Flex 4.1 and start playing with the layoutDirection and direction properties.

For more information, see Adobe Flex Layout Mirroring.


This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 Unported License.

More Like This

  • Localization in Flex – Part 1: Compiling resources into an application
  • Tips for using Flex containers
  • Flash Builder 4によるデベロッパーの生産性改善
  • A brief overview of the Spark architecture and component set
  • Defining and using new skin parts in a Spark skin
  • Building an icon-checkbox component with Flex 3
  • Creating components and enforcing separation of concerns with Flex
  • Creating Flex components
  • AdvancED Flex 3 excerpt: Sculpting interactive business intelligence interfaces
  • Introducing the MXML and ActionScript languages

製品

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • モバイルアプリ
  • Photoshop
  • Touch Apps

ソリューション

  • デジタルマーケティング
  • コンテンツオーサリング
  • Web Experience Management

業種別ソリューション

  • 教育
  • 金融機関

サポート

  • ヘルプ&サポート
  • 注文と返品
  • ダウンロードに関するヘルプ
  • ユーザー登録に関するヘルプ

ラーニング

  • ADC: Adobe Developer Center
  • Adobe TV
  • Design Magazine
  • Photoshop Magazine
  • Focus In

ご購入方法

  • アドビストア
  • アカデミックストア
  • アドビライセンスストア
  • ボリュームライセンスについて
  • 販売パートナー
  • キャンペーン情報

ダウンロード

  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player

会社情報

  • プレスルーム
  • パートナープログラム
  • 企業の社会的責任(英語)
  • 採用情報
  • 投資家の皆様へ(英語)
  • イベント&セミナー
  • Legal(英語)
  • セキュリティ
  • お問い合わせ
国・地域および言語の選択 日本(変更)
国・地域および言語の選択 閉じる

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 © 2012 Adobe Systems Incorporated. All rights reserved.

利用条件 | プライバシーポリシーとCookie (更新)

Reviewed by TRUSTe: site privacy statement