- 浏览: 1076334 次
- 性别:
- 来自: 杭州
文章分类
- 全部博客 (399)
- C++ (39)
- Java (74)
- Java界面开发学习笔记 (4)
- Java用户的c++之旅 (0)
- 自言自语 (12)
- DSP (1)
- MCU (0)
- CG (0)
- Jabber (0)
- Gloox (0)
- Linux (11)
- Windows (19)
- Networks (4)
- Jobs (0)
- PHP (1)
- JSP (2)
- 生活 (35)
- C (2)
- Qt4 (2)
- C# (50)
- WPF (5)
- ASP (2)
- FLEX (47)
- SQL (20)
- JavaScript (12)
- SharePoint (6)
- GWT (1)
- Dojo (9)
- HTML (11)
- Others (7)
- 如何安装配置系列 (7)
- UML (2)
- Android (3)
- alibaba (1)
最新评论
-
zxjlwt:
学习了http://surenpi.com
Firefox插件开发: Hello World! -
ylldzz:
楼主知道MVEL怎么调试么
MVEL简介及快速使用 -
blueman2012:
您好,可否提供源码下载,我把您的代码贴过来后,好多报错的,谢谢 ...
Log4J日志解析 -
svygh123:
你的游标都没有关闭呢!
MYSQL游标嵌套循环示例 -
dizh:
写的很好啊
MVEL简介及快速使用
Generating a Flex Library Project
Start out by entering the following in a terminal window:
1.
mvn archetype:generate \
2.
-DarchetypeRepository=http://repository.sonatype.org/content/
groups
/public \
3.
-DarchetypeGroupId=org.sonatype.flexmojos \
4.
-DarchetypeArtifactId=flexmojos-archetypes-library \
5.
-DarchetypeVersion=3.7.1
Figure 7 shows the output of running the generate archetype for a Flex library project.
Flexmojos generate:archetype flexmojos-archetypes-library
The generated folder structure for the samplelib project should be as shown in Figure 8.
Generated folder structure for a Flex library project, samplelib
This time a class named App.as is generated, which contains the following:
Next, easily build and package the Flex library using “mvn install”. The output of this process creates a SWC file, samplelib-1.0-SNAPSHOT.swc, which can be linked to a Flex application and used as a Flex library typically is.
You can also generate a multimodule project using the archetypeArtifactId as flexmojos-archetypes-modular-webapp but I will not illustrate that here. There is no Flexmojos archetype to generate an AIR application or a pure AS3 project.
Next, we try and synch up the Flexmojos’ approach with that of Flash Builder’s.
Importing Flexmojos projects into Flash Builder
Flexmojos projects follow the Maven idiom of development and so keep the source and output in folders that follows the Maven conventions. This however doesn’t by itself work with Flash Builder. For example, Flash Builder keeps its Main.mxml Flex application file within the src folder in the project, whereas Flexmojos keeps that within src/main/flex. To convert a Flexmojos project to a Flash Builder structure you could use the flexmojos:flexbuilder plugin goal.
To see how this works, first generate a new Flex application. I call it samplefbapp. Once created modify the project pom.xml to include the Flexmojos repository, as illustrated earlier. Finally run “mvn org.sonatype.flexmojos:flexmojos-maven-plugin:3.7.1:flexbuilder”. This generates artifacts for Eclipse so that the project can be easily imported into it. The generated structure is as shown in Figure 9. To simply run “mvn flexmojos:flexbuilder” instead with its fully qualified name, add the following to settings.xml file within the “.m2” folder:
1.
<
pluginGroups
>
2.
<
pluginGroup
>com.sonatype.maven.plugins</
pluginGroup
>
3.
<
pluginGroup
>org.sonatype.plugins</
pluginGroup
>
4.
</
pluginGroups
>
Create the settings.xml file if it doesn’t already exist.
Folder structure and generated files after running “mvn flexmojos:flexbuilder”
To make sure this actually works and is Eclispe friendly, I open up the Eclipse instance with the Flash Builder plugin and try and import the project into it. Figure 10 to 14 show the steps involved in importing the project. Figure 13 shows that I use the latest version of Flash Builder but chose the Flex 3.5 SDK to keep things consistent. Once the project is available in Flash Builder, you can use Flash Builder to develop the application.
Import existing project into workspace
Select existing project from the file system
Project linked to the source on the file system
Choose Flex 3.5 SDK
Main.mxml of the project, as viewed in Flash Builder
So far we started with Flexmojos but that may not be the case always. If you start out with Flash Builder and would like to use Maven to build it without any modifications, then remember to configure the parameters like sourecDirectory and testDirectory appropriately in the pom.xml that you will define for the project.
So far we have looked at generating Flex application and library projects and importing Maven Flex projects into Flash Builder. Next, we take a Flex and an AIR project and use Maven to build it.
Building a Flex Application
First create a Flex 4 project using Flash Builder. I name it flex4app. Figure 15 shows a snapshot of the project create wizard.
Create flex4app, a Flex 4 application
I named my Application file Main.mxml. The contents of Main.mxml are as follows:
01.
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
02.
<
s:Application
xmlns:fx
=
"http://ns.adobe.com/mxml/2009"
03.
xmlns:s
=
"library://ns.adobe.com/flex/spark"
04.
xmlns:mx
=
"library://ns.adobe.com/flex/mx"
minWidth
=
"955"
minHeight
=
"600"
>
05.
<
fx:Declarations
>
06.
<!-- Place non-visual elements (e.g., services, value objects) here -->
07.
</
fx:Declarations
>
08.
<
s:Button
id
=
"myButton"
label
=
"My Button"
/>
09.
</
s:Application
>
Flash Builder generates much of the code above. I only added the line that includes a Spark Button that had a label: “My Button”.
Next, add a pom.xml file at the root of the project. Add the following to pom.xml:
01.
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
02.
<
project
xmlns
=
"http://maven.apache.org/POM/4.0.0"
03.
xmlns:xsi
=
"http://www.w3.org/2001/XMLSchema-instance"
04.
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
06.
<
modelVersion
>4.0.0</
modelVersion
>
07.
08.
<
groupId
>com.treasuryofideas</
groupId
>
09.
<
artifactId
>flex4app</
artifactId
>
10.
<
version
>1.0-SNAPSHOT</
version
>
11.
<
packaging
>swf</
packaging
>
12.
13.
<
name
>flex 4 app</
name
>
14.
15.
<
build
>
16.
<
sourceDirectory
>src</
sourceDirectory
>
17.
18.
<
plugins
>
19.
<
plugin
>
20.
<
groupId
>org.sonatype.flexmojos</
groupId
>
21.
<
artifactId
>flexmojos-maven-plugin</
artifactId
>
22.
<
version
>3.7.1</
version
>
23.
<
extensions
>true</
extensions
>
24.
<
dependencies
>
25.
<
dependency
>
26.
<
groupId
>com.adobe.flex</
groupId
>
27.
<
artifactId
>compiler</
artifactId
>
28.
<
version
>4.0.0.14159</
version
>
29.
<
type
>pom</
type
>
30.
</
dependency
>
31.
</
dependencies
>
32.
</
plugin
>
33.
</
plugins
>
34.
</
build
>
35.
36.
<
dependencies
>
37.
<
dependency
>
38.
<
groupId
>com.adobe.flex.framework</
groupId
>
39.
<
artifactId
>flex-framework</
artifactId
>
40.
<
version
>4.0.0.14159</
version
>
41.
<
type
>pom</
type
>
42.
</
dependency
>
43.
</
dependencies
>
44.
45.
<
repositories
>
46.
<
repository
>
47.
<
id
>flexmojos</
id
>
48.
<
url
>http://repository.sonatype.org/content/groups/flexgroup/<;/
url
>
49.
</
repository
>
50.
</
repositories
>
51.
52.
</
project
>
Lets traverse through the contents of the pom file to see what we have added. The first few lines of the file are the XML/XSD schema and namespace definitions. Then there are the four Maven co-ordinates: groupId, artifactId, version and packaging that identify the project. After the Maven coordinates is the name XML tag that attaches a name to the project. Besides what is already listed so far the pom file contains the following:
- build parameters – includes source directory and plugin defintions
- dependencies – specifies dependencies, if any
- repositories – in addition to the central Maven repository and required specifically for the project
Looking a little closely at the build parameters you will notice that the “sourceDirectory” points to “src” and not the default “src/main/flex”. The project source code resides in the “src” directory so this is required. The build tags also specifies the plugin, which is org.sonatype.flexmojos:flexmojos-maven-plugin:3.7.1. Within the plugin definition additional dependency on a specific compiler is specified. By default, each plugin version supports a specific Flex compiler. However, one can explicitly specify a particular compiler version, if required. You can read more about this online here.
In my specific setup the Flex 4 SDK is version 4.0.0.14159 so that is the version of the Flex compiler the Flexmojos plugin is dependent on. You can look up your specific SDK version by expanding out the framework swc details in the “Flex Build Path” in your Eclipse/Flash Builder installation as shown in Figure 16.
Framework version as visible in the Flex Builder Path
If you scroll down to the section that specifies the dependencies, you will notice that the Flex framework dependency also specifies the same version: 4.0.0.14159. This is required to make sure the compiler and SDK versions are both specified correctly for the Flexmojos plugin to work without errors. The definition in the repository section is something you are already familiar with so I will skip explaining it again here.
Once the pom is ready and saved, open up a terminal window, browse to the folder where the pom is and run “mvn install”. Again, you should see Maven downloading and building, at the end of which you should see a message saying the build was successful. Once compete you should find flex4app-1.0-SNAPSHOT.swf in the newly created “target” directory within your project. Review Figure 17 and Figure 18 to find out the newer files and directories that “mvn install” creates.
flex4app project structure before running “mvn install”
flex4app project structure after running “mvn install”
If you open flex4app-1.0-SNAPSHOT.swf in a local Flash Player or a browser that has the Flash plugin installed then you should see a Flex application with a spark button labeled “My Button” as shown in Figure 19.
Flex 4 Application build using Maven
We have been running Flexmojos install build lifecycle goal for a while but haven’t really dug deeper into what all is running as a result of executing this goal. So, it may be worthwhile to note which exact goals are executed and in what order. Flexmojos follows the standard Maven build lifecycle but introduces three additional goals, namely, compile-swc, test-compile and test-run. The goals are executed in the following order:
- resources:resources
- flexmojos:compile-swc
- resources:testResources
- flexmojos:test-compile
- flexmojos:test-run
- install-install
- deploy:deploy (which we don’t run as a part of mvn install)
When you use Flash Builder to compile a Flex application, you get the SWF and an html wrapper for the SWF. You can generate an html wrapper using Maven as well. All you have to do is include the following, within the plugin tags of your pom’s build tags:
01.
<
executions
>
02.
<
execution
>
03.
<
goals
>
04.
<
goal
>wrapper</
goal
>
05.
</
goals
>
06.
<
configuration
>
07.
<
parameters
>
08.
<
swf
>${build.finalName}</
swf
>
09.
<
width
>100%</
width
>
10.
<
height
>100%</
height
>
11.
</
parameters
>
12.
</
configuration
>
13.
</
execution
>
14.
</
executions
>
and run “mvn install” again. Now you should see a number of newer files to support the html wrapper. Look at Figure 20 to see the project structure after generating the html wrapper. You will also see flex4app-1.0-SNAPSHOT.html that wraps the Flex application.
Flex4app project structure after mvn install with html wrapper
You can learn more about html wrapper and its possible configurations at the Flexmojos wiki: https://docs.sonatype.org/display/FLEXMOJOS/Html+Wrapper+Mojo
With a successful Flex 4 and Maven experience, lets move on to the last topic of this article, which illustrates building an AIR application with Maven.
Building an Adobe AIR application
Create an AIR application and name it airapp. Figure 21 depicts the first screen of the project creation wizard.
Create an AIR application
Add a pom.xml file to the root of the project. Add the following to pom.xml:
01.
<
project
xmlns
=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://
02.
www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://
03.
maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
04.
<
modelVersion
>4.0.0</
modelVersion
>
05.
<
groupId
>com.treasuryofideas</
groupId
>
06.
<
artifactId
>airapp</
artifactId
>
07.
<
version
>1.0-SNAPSHOT</
version
>
08.
<
name
>Flex 4 AIR Application</
name
>
09.
<
properties
>
10.
<!-- the application name which must match the main mxml file
11.
and application descriptor file names -->
12.
<
application.name
>Main</
application.name
>
13.
<
flex.framework.version
>4.0.0.14159</
flex.framework.version
>
14.
<
keystore.file
>${basedir}/cert4air.p12</
keystore.file
>
15.
<
keystore.password
>secret</
keystore.password
>
16.
</
properties
>
17.
<
packaging
>swf</
packaging
>
18.
<
build
>
19.
<
sourceDirectory
>src</
sourceDirectory
>
20.
<
plugins
>
21.
<
plugin
>
22.
<
groupId
>org.sonatype.flexmojos</
groupId
>
23.
<
artifactId
>flexmojos-maven-plugin</
artifactId
>
24.
<
version
>3.7.1</
version
>
25.
<
extensions
>true</
extensions
>
26.
27.
<
dependencies
>
28.
29.
<
dependency
>
30.
<
groupId
>com.adobe.flex</
groupId
>
31.
<
artifactId
>compiler</
artifactId
>
32.
<
version
>${flex.framework.version}</
version
>
33.
<
type
>pom</
type
>
34.
</
dependency
>
35.
36.
<
dependency
>
37.
<
groupId
>com.adobe.flex.compiler</
groupId
>
38.
<
artifactId
>adt</
artifactId
>
39.
<
version
>${flex.framework.version}</
version
>
40.
</
dependency
>
41.
</
dependencies
>
42.
43.
<
configuration
>
44.
<!-- set this to true to allow the plugin to find the special Flex Builder/Flash Builder
45.
string in the application descriptor which is normally in site the <
content
> tag. If you set
46.
this to false or omit it entirely, the plugin will expect there to be an ${output} token
47.
in that tag. Placing that token in the application descriptor will prevent the Export Release
48.
Build function in Flex Builder/Flash Builder for working
49.
-->
50.
51.
<
flexBuilderCompatibility
>true</
flexBuilderCompatibility
>
52.
53.
<
sourceFile
>${application.name}.mxml</
sourceFile
>
54.
<
descriptorTemplate
>${basedir}/src/${application.name}-app.xml</
descriptorTemplate
>
55.
<
keystore
>${keystore.file}</
keystore
>
56.
<
storepass
>${keystore.password}</
storepass
>
57.
58.
<!--optionally include files in the AIR package -->
59.
60.
margin-left: 18
发表评论
-
一些Flex炫效果网址
2011-01-20 19:22 2779转帖 :http://bbs.airia.cn/FLEX/th ... -
maven 手动加载第三方jar、zip包
2010-12-18 17:12 4131使用maven搭建工程时,难免要加载大量的第三方的jar ... -
TWaver Flex Online Demo & Quick Start
2010-08-30 12:42 1904TWaver Flex开发环境的搭建: ... -
[转]Flex 开发必备10武器
2010-08-26 18:51 137101. Tour de Flex 02. ... -
[转]12种RIA常用布局
2010-08-26 18:50 1550原文地址:http://ria9.com/flashbuild ... -
unable to open “frameworks\locale\zh_CN’ 解决方法
2010-04-03 14:38 5279unable to open “frameworks\loca ... -
Flex + ASP.Net + FlourineFX 示例
2010-04-03 14:31 4236这里简单介绍使用Flex Builder 4 与 VS2008 ... -
Flex Canvas - Rounded Corners & cornerRadius
2009-12-04 17:31 2639问题在使用Canvas时想实现圆角的效果,定义了Canva ... -
Flex获取XML根节点属性的问题
2009-11-27 09:42 2950在读写XML的根节点属性的时候,会用两种方法: var xm ... -
在Flex中使用Json (转载收藏)
2009-11-21 21:14 1526要用到JSON,看了一篇(http://bbs.actio ... -
Flex画线动画一例
2009-08-19 13:38 3424<?xml version="1.0&qu ... -
给Flex导出的SWF减减肥
2009-08-19 09:43 2040第一步:分离运行库,使用RSL减小FLEX生成文件的体积 要 ... -
Image组件怎么才能非等比例拉伸图片
2009-08-18 11:06 1897设置maintainAspectRatio="fal ... -
flex与flash的交互
2009-08-15 19:19 1470老是听到群里的人问flex怎样与flash交互,一一回答的太多 ... -
Flex3特效的基本用法---触发器
2009-08-14 16:50 1802触发器在Flex3的特效实现中起着重要作用,对于Flex3中的 ... -
Flash SandBox 安全问题解决
2009-08-12 17:55 1607今天在做flex相册, 在本地环境中运行正常,但是拷出来的时候 ... -
Flex特效
2009-08-10 22:56 1928这里面有许多特效很酷,希望对大家有帮助。 1.旋转 效果: ... -
Flex组件开发总结
2009-08-10 22:48 13291.如何监听键盘事件? <mx:TextArea id ... -
解决Error: Error #2060: 安全沙箱冲突:ExternalInterface 调用者
2009-08-10 10:09 7611SecurityError: Error #2060: 安全沙 ... -
Flex App 部署到 IIS
2009-08-08 06:43 1602直接将bin文件夹拷贝到C:\inet\wwwroot下即可, ...
相关推荐
Ideal for experienced developers with or without a background in Flex, Getting Started with Flex 4 shows you how to take advantage of your existing skills. You'll quickly discover how easy RIA ...
Learn iPhone and iPad Programming via Tutorials! If you're new to iOS or Swift, or to programming in general, learning how to write an app can seem incredibly overwhelming.
graph slam tutorial :从推导到应用3(g2o版程序),包含文档读取,及后端优化
Getting Started with C++ Audio Programming for Game Developers covers a broad range of topics – from loading and playing audio files to simulating sounds within a virtual environment and implementing...
Chapter 1: Getting Started Chapter 2: IDE Integration with Maven Chapter 3: Maven Lifecycle Chapter 4: Essential Maven Plugins Chapter 5: Dependency Management Chapter 6: Code Quality Plugins Chapter ...
Tutorial 1: Setting up DirectX 11 with Visual Studio Tutorial 2: Creating a Framework and Window Tutorial 3: Initializing DirectX 11 Tutorial 4: Buffers, Shaders, and HLSL Tutorial 5: ...
This practical tutorial will help you quickly get up and running with Raspberry Pi Zero to control hardware and software and write simple programs and games. You will learn to build creative programs...
Getting Started with Grunt: The JavaScript Task Runner will enable you to create your very own Grunt environments from scratch and fully utilize Grunt's large feature set to effectively solve your ...
Chapter 3: Getting Started with Web Applications 49 Web Applications 50 Web Application Lifecycle 51 Web Modules: The hello1 Example 53 Configuring Web Applications: The hello2 Example 62 Further...
《Java EE 6 Tutorial: Basic Concepts, Fourth Edition》是一本面向新手及中级Java开发者的指南书籍,旨在帮助他们深入理解Java平台企业版6(Java EE 6)的各项特性与技术。本书由Oracle公司Java EE 6文档团队成员...
Getting Started with ownCloud is a practical handbook that provides step-by-step installation and scaling instructions. It will also give you an excellent understanding into how ownCloud can be ...
本书教您如何使用Ruby on Rails开发和部署真正的,具有工业实力的Web应用程序,Ruby on Rails是为诸如Twitter,Hulu,GitHub和Yellow Pages等顶级网站提供支持的开源Web框架。
MRTK.HoloLens2.Unity.Tutorials.Assets.GettingStarted.2.3.0.2
Doing Bayesian Data Analysis, A Tutorial Introduction with R and BUGS, is for first year graduate students or advanced undergraduates and provides an accessible approach, as all mathematics is ...
.NET Programming with Visual C++: Tutorial, Reference, and Immediate Solutions By 作者: Max Fomitchev ISBN-10 书号: 1138436399 ISBN-13 书号: 9781138436398 Edition 版本: 1 出版日期: 2017-07-27 Pages:...
[Chinese Simplified] Getting Started with Adobe Illustrator for Beginners Tutorial [DownSub.com].srt
2. **创建视图:** 选择“视图”选项,输入视图名称(例如:ZV_TUTORIAL1),并指定视图类型。通常情况下,我们会选择标准视图。点击“创建”。 3. **设计视图布局:** 进入视图编辑器,您可以根据需求设计视图的...
Tutorial #1 Getting started.mp4