我可以从相同的源代码生成 Flex web 和 Air 桌面应用程序吗? [英] Can I generate a Flex web and Air desktop app from the same source code?

查看:26
本文介绍了我可以从相同的源代码生成 Flex web 和 Air 桌面应用程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Air 的新手.我有一个现有的 Flex 2 应用程序,我正在考虑将其引入 Flexbuilder 3.我的问题是我是否可以使用相同的基本应用程序(和源代码)来制作 Air 版本,或者我是否必须维护以分离代码树: 一种用于 Air 版本,一种用于 Flex/SWF 版本?

I'm new to Air. I've got an existing Flex 2 application which I'm considering bringing into Flexbuilder 3. My question is can I use the same base application (and source code) to make the Air version, or would I have to maintain to separate code trees: one for the Air version and one for the Flex/SWF version?

推荐答案

我发现从同一源创建 Flex 和 AIR 应用程序的最佳方法是对几乎所有代码使用核心库项目,并使用单独的Flex 和 AIR 应用程序的小型项目.

The best approach I've found to creating both Flex and AIR applications from the same source, is to use a core library project for almost all code, with separate small projects for the Flex and AIR applications.

有两个关键概念使其非常强大且可维护,不仅允许两个应用程序,而且允许许多版本"(如果您愿意的话).

There are two key concepts that make this very powerful and maintainable, allowing for not just two applications, but for many "editions" if you're so inclined.

  1. 模块:- 如果核心应用程序是实际上是一个模块(或一个模块加载其他模块)你将能够轻松创建存根 Flex 和 AIR基本上是应用程序在那里设置项目属性,跨模块的参考类通信,然后简单地加载核心应用模块模块加载器.

  1. Modules:- If the core application is actually a module (or a module that loads other modules) you'll be able to easily create stub Flex and AIR applications that are basically there to set project properties, reference classes for cross-module communication, and then simply load the core application module with a ModuleLoader.

工厂对象:- 当有您想在 AIR 上做的事情你不能的桌面应用程序在 Flex 应用程序中执行,或任何如果你想要一些东西不同的工作方式应用程序,一个工厂对象创建一个项目的实例特定的课程是一个很好的方式它.例如,你可以打电话给你的保存"功能,用于 AIR 保存到文件系统,但对于 Flex 调用网络服务.

Factory Objects:- When there are things you want to do on the AIR desktop application that you can't do in the Flex application, or any case where you want something to work differently across applications, a factory object that creates an instance of a project specific class is a great way to do it. for example, you can call your "save" function, which for AIR saves to the file system, but for Flex calls a web service.

看看 Todd Prekaski 的优秀的 Flex DevNet 文章构建 Flex 和 Adob​​e AIR来自相同代码库的应用程序关于如何做到这一点.

Have a look at Todd Prekaski's excellent Flex DevNet article on Building Flex and Adobe AIR applications from the same code base on how to do this.

一旦您创建了一个 Flex 库项目,您将在其中创建您的主模块,请创建您的 Flex 和 AIR 应用程序项目.在两个应用程序项目的属性中,将库项目 src 目录添加到 Flex Build Path.在项目设置中,您还需要将模块添加到 Flex Modules 部分,设置选项以优化项目.

Once you've created a Flex Library project where you're going to create your main module, create your Flex and AIR application projects. In the properties of the two application projects add the library project src directory to the Flex Build Path. While in the project settings you'll also need to add the modules to the Flex Modules section, setting the option to optimise for the project.

这篇关于我可以从相同的源代码生成 Flex web 和 Air 桌面应用程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆