白手起家学习使用flex (1) 使用Flex SDK 4.5 建立第一个项目

发布时间: 2011-11-24 15:18:00

1. 下载flex SDK:
2. 这篇文章,如何搭建环境:

基本上,对于AIR, 先下载ZIP包( ,然后解压缩,然后把bin 路径添加到PATH 系统变量中。

3. 先把台阶弄低点,从HTML 入手(见这个文章: Creating your first HTML-based AIR application with the AIR SDK  )

Create the project files
Create the AIR application descriptor file
Create the application HTML page
Test the application
Create the AIR installation file
Next Steps
For a quick, hands-on illustration of how Adobe® AIR® works, use these instructions to create and package a simple HTML-based AIR “Hello World” application.

To begin, you must have installed the runtime and set up the AIR SDK. You will use the AIR Debug Launcher (ADL) and the AIR Developer Tool (ADT) in this tutorial. ADL and ADT are command-line utility programs and can be found in the bin directory of the AIR SDK (see Installing the AIR SDK). This tutorial assumes that you are already familiar with running programs from the command line and know how to set up the necessary path environment variables for your operating system.

Note: If you are an Adobe® Dreamweaver® user, read Create your first HTML-based AIR application with Dreamweaver.
Note: HTML-based AIR applications can only be developed for the desktop and the extendedDesktop profiles. The mobile and tv profiles are not supported.
Create the project files

Every HTML-based AIR project must contain the following two files: an application descriptor file, which specifies the application metadata, and a top-level HTML page. In addition to these required files, this project includes a JavaScript code file, AIRAliases.js, that defines convenient alias variables for the AIR API classes.

Create a directory named HelloWorld to contain the project files.
Create an XML file, named HelloWorld-app.xml.
Create an HTML file named HelloWorld.html.
Copy AIRAliases.js from the frameworks folder of the AIR SDK to the project directory.

这个文件应该是在这里: D:\flex_sdk_4.5.1\frameworks\libs\air

1. 首先,建立个文件夹,名字随便取。
2. 在这个 新文件夹中,建立几个文件。 
AIRAliases.js  hello_bird.html  hellow_bird-app.xml

3. 比较关键的 项目描述文件的内容:

  1 <application xmlns="">
  2     <id>examples.html.HelloWorld</id>
  3     <versionNumber>0.1</versionNumber>
  4     <filename>hello_bird</filename>
  5     <initialWindow>
  6         <content>hello_bird.html</content>
  7         <visible>true</visible>
  8         <width>400</width>
  9         <height>200</height>
 10     </initialWindow>
 11 </application>

注意:   xmlns=""  是行不通的。会出现错误: invalid application descriptor: Unknown namespace:

把2.7 改成 2.6 就好了。(参考: )

4. 然后,对应的HTML 文件(hello_bird.html) 的内容为:
  1 <html>
  2     <head>
  3         <script src="AIRAliases.js" type="text/javascript"></script>
  4         <script type="text/javascript">
  5         function appLoad(){
  6             air.trace("Hello World in console");
  7         }
  8         </script>
  9         <title>Hello World</title>
 10     </head>
 11     <body onLoad="appLoad()">
 12         <h1>Hello World in HTML file! !!!</h1>
 13     </body>
 14 </html>

5. 编译,运行:
cd <your folder name>
adl hellow_bird-app.xml

可以看到console和HTML的内容都显示了出来。 还是挺爽的。


$ adt -package -storetype pkcs12 -keystore sampleCert.pfx HellowBird.air hello_bird.html hellow_bird-app.xml AIRAliases.js
D:\workspace\bird_bird\hello_bird\hello_bird.html: error 101: Namespace is missing

太郁闷了。 这个Namespace 搞不定啊。没任何资料。 官方给的2个: 2.7, 3.0 都不行。莫非是我在公司防火墙? 但是 2.0, 2.6 都可以用啊。

算了, 先放着。 反正上午开始的 1G 的flash builder 5已经下载好了。 走走action script的路子吧。