Adobe
产品
Acrobat
Creative Cloud
创意套装
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
更多产品
解决方案
数字营销
数字媒体
教育
金融服务业
政府部门
网页体验管理
更多解决方案
学习帮助下载公司
商店
在线商店
批量许可
查找经销商
搜索
 
信息 登录
欢迎,我的支持
我的帐户
注销
为何登录?登录后可以管理您的帐户,访问试用版下载、产品扩展和社区区域等。
Adobe
产品 分类 购买   搜索  
解決方案 公司
学习
登录 注销 我的货物 我的支持
Date Date
Qty:
Subtotal
Checkout
Adobe 开发者中心 / Flex 开发人员中心 / 手机 Flex Test Drive /

试用Flex开发移动应用之 -- 风格化应用程序

作者 Adobe

adobe_logo

创建日期

6 December 2010

页面工具

在 Facebook 上共享
在 Twitter 上共享
在 LinkedIn 上共享
书签
打印

Tags

要求

用户级别

全部

视频 | 代码 | 教程 

新增FXG图形

 

缺少 Flash player 您必须装有 Flash 10? 您必须装有 Flash 10?

下载示例代码 (ZIP, 14.8 MB)

代码

AddEditView.mxml 

<?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" xmlns:valueObjects="valueObjects.*" xmlns:employeeservice="services.employeeservice.*" title="Add Employee" add="view1_addHandler(event)" xmlns:assets="assets.*"> <!-- more code --> <s:Scroller> <!-- more code --> </s:Scroller> <assets:ToolAreaBackground left="0" right="0" bottom="0" height="100"/> <s:Button id="saveBtn" .../> <s:Button id="cancelBtn" .../> </s:View>

ToolAreaBackground.mxml 

<?xml version="1.0" encoding="UTF-8"?> <Graphic version="2.0" xmlns=http://ns.adobe.com/fxg/2008 viewWidth="80" viewHeight="26" scaleGridLeft="2" scaleGridTop="2" scaleGridRight="78" scaleGridBottom="24"> <Rect x="0" y="0" width="80" height="26"> <fill> <SolidColor color="#618C56"/> </fill> </Rect> <Rect x="0" y="0" width="80" height="26" > <fill> <LinearGradient scaleX="26" rotation="90"> <GradientEntry color="#ffffff" ratio="0" alpha="0.25"/> <GradientEntry color="#fafafa" ratio="0.22" alpha="0.25"/> <GradientEntry color="#e8e8e8" ratio="1" alpha="0.05"/> </LinearGradient> </fill> <stroke> <LinearGradientStroke scaleX="26" rotation="90" weight="1"> <GradientEntry color="#ffffff" ratio="0" alpha="0.25"/> <GradientEntry color="#ffffff" ratio="1" alpha="0.15"/> </LinearGradientStroke> </stroke> </Rect> </Graphic>

教程

在本教程中,您将学习如何通过加入FXG图形来改变你的应用程序的外观。

FXG是一种用来定义静态图形的声明语法(declarative syntax). 它定义了一种图形(graphics)交换格式, 使得的各种产品可以共享一个文件格式, 它使你可以创建可扩展的矢量图并将它作为组件应用到你的Flex应用程序中. 一个典型的工作流程是:通过图形工具(如: Adobe Illustrator, Adobe Photoshop, 或 Adobe Fireworks)生成一个图形,然后将它保存或导出成FXG格式. 这个FXG文件就会作为一个组件用在你的应用程序中. FXG文件是被Flex编译器编译成优化的, 低层次的Flash Player码, 这样在运行时会很快显示.

步骤1: 检查FXG文件

打开在assets文件夹中的ToolAreaBackground.fxg

它包含了一套标签来代表矢量图形的设置. 它定义了一个灰色的不透明矩形和一个主要是透明的矩形,它有一个从上到下的渐变添充(a gradient fill overlaid on top of the first to provide some depth).

载入FXG文件
图1. 载入FXG文件

步骤2: 添加FXG图形,这样矩形就可以在按钮下方出现

在AddEditView.mxml 中返回源码方式, 创建ToolAreaBackground的实例, 它将显示在按钮的下方.

为了将矩形显示在按钮的下方, 你需要将ToolAreaBackground tag放在Button tags的前面. 在默认情况下, 对象(object)会按照它们在MXML列表中的顺序依次显示.

一定要从Content Assist中选者ToolAreaBackground class, 这样命名空间(name space)就为你而写(见图2).

用Content Assis添加ToolAreaBackground
图2. 用Content Assis添加ToolAreaBackground

你的代码将是这样的:

</s:Scroller> <assets:ToolAreaBackground/> <s:Button .../>

新的命名空间(namespace)的声明将如下显示:

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:valueObjects="valueObjects.*" xmlns:employeeservice="services.employeeservice.*" title="Add Employee"add="view1_addHandler(event)" xmlns:assets="assets.*">

步骤3: 调整矩形大小

调整ToolAreaBackground的大小, 以便它可以填充滚轮(Scroller)下方的空间。

为了填补在屏幕底部的空间,设置ToolAreaBackground左,右和底部属性值为0, 高度为100.

<assets:ToolAreaBackground left="0" right="0" bottom="0" height="100"/>>

返回设计模式,运行应用程序,并翻到添加和修改(add and edit)这一屏幕,你应该能看见按钮下方有个灰色矩形(见图3).

在按钮下看见一个新的矩形
图3 . 在按钮下看见一个新的矩形

步骤4:更改矩形的颜色

返回ToolAreaBackground.fxg,改变矩形的颜色为 与应用程序的相配的铬的颜色: #618C56

您的代码应如下所示:

<?xml version="1.0" encoding="UTF-8"?> <Graphic version="2.0" xmlns="http://ns.adobe.com/fxg/2008" viewWidth="80" viewHeight="26" scaleGridLeft="2" scaleGridTop="2" scaleGridRight="78" scaleGridBottom="24"> <Rect x="0" y="0" width="80" height="26"> <fill> <SolidColor color="#618C56"/> </fill> </Rect>

确认保存了FXG文件, 然后返回到AddEditView.mxml设计模式下 或者 运行应用程序. 你现在应该可以看到在按钮下方有一个绿色的矩形(见图4).

看到新矩形的颜色
图4. 看到新矩形的颜色

这样就结束了你的Flash Builder Burrito的试用。你已经学习了建立一个移动Flex应用程序检索,显示,更新,添加和删除数据库中的数据,你还学习了调试,打包和定制应用程序。

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

本产品经 Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License 许可。Adobe 提供超出该许可范围、与本产品包含的代码示例相关的权限。

More Like This

  • 手机 Flex Test Drive:在一小时内构建一个手机应用程序
  • 手机 Flex Test Drive:在一小时内构建一个手机应用程序
  • Test Drive:添加应用程序功能
  • 移动 Flex Test Drive:测试和调试代码
  • Test Drive:将您的应用程序部署到网络服务器
  • Test Drive:将您的应用程序部署到网络服务器
  • Flex Test Drive for Mobile: Modify the application appearance
  • 手机 Flex Test Drive:在一小时内构建一个手机应用程序
  • Test Drive:添加应用程序功能
  • Test Drive:添加应用程序功能

Tutorials and 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

Flex user forum

More
07/25/2011 Flash Player Debug Issues - Safari 5.1 & Chrome 13
04/22/2012 Loader png - wrong color values in BitmapData
04/22/2012 HTTPService and crossdomain.xml doesn't work as expected
04/23/2012 Memory related crashes in Flex application

Flex Cookbook

More
04/06/2012 How to detect screen resize with a SkinnableComponent
02/29/2012 Embed Stage3D content inside Flex application components
02/15/2012 Custom WorkFlow Component
02/09/2012 Using Camera with a MediaContainer instead of VideoDisplay

产品

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • 移动应用程序
  • Photoshop
  • Touch Apps

解决方案

  • 数字营销
  • 数字媒体
  • 网页体验管理

行业

  • 教育
  • 金融服务业
  • 政府部门

帮助

  • 产品帮助中心
  • 订货和退货
  • 下载和安装
  • 我的 Adobe

学习

  • Adobe 开发人员连接
  • Adobe TV
  • 培训和认证
  • 论坛
  • 设计中心

购买方式

  • 在线商店
  • 批量许可
  • 查找经销商

下载

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

公司

  • 新闻编辑室
  • 合作伙伴计划
  • 公司社会责任
  • 工作机会
  • 投资者关系
  • 事件
  • 法律
  • 安全
  • 联系 Adobe
选择您的地区 中国(更改)
选择您的地区 关闭

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.

使用条款 | 隐私政策和 Cookies (更新)

京 ICP 备 10217899 号 京公网安备 110105010404