小程序flex:1_Flex 2:瞬间丰富的Internet应用程序!

小程序flex:1

You may have heard some buzz recently about Adobe’s release of Flex 2. Flex is a collection of technologies that combine to give developers a strong framework for building Rich Internet Applications. You may already be familiar with one of those technologies: Flash.

您可能最近听说过有关Adobe发行的Flex 2的一些嗡嗡声。Flex是一组技术的组合,这些技术相结合为开发人员提供了一个构建Rich Internet Application的强大框架。 您可能已经熟悉其中一种技术:Flash。

RIAs are lightweight online programs that provide users with a more dynamic and interactive experience than they might find in a normal web page. Like web applications built with AJAX, Flex applications feel much more responsive, because a new web page doesn’t need to be loaded every time the user takes action. However, unlike working with AJAX, Flex developers don’t need to worry about dealing with differing browser implementations of JavaScript or CSS — you can focus all of your time on the application’s development, because the framework runs on Adobe’s cross-platform Flash Player.

RIA是轻量级的在线程序,可为用户提供比普通网页更动态和交互式的体验。 就像使用AJAX构建的Web应用程序一样,Flex应用程序的响应速度也要快得多,因为不需要在用户每次执行操作时都加载新的网页。 但是,与使用AJAX不同,Flex开发人员无需担心处理不同JavaScript或CSS浏览器实现-您可以将所有时间都花在应用程序的开发上,因为该框架在Adobe的跨平台Flash Player上运行。

Flex hit the ground running with the release of Flash Player 9 in June of this year. Thanks to a new internal architecture, Flash Player 9 runs up to ten times faster than previous releases. ActionScript, Flash’s programming language, also received an extensive update that will help developers migrating from other languages feel more at home. New features include strong typing, regular expressions, and native support for XML thanks to ECMAScript for XML (E4X). Flash 9 runs on Windows and Mac OS X, and a Linux player is currently in development.

Flex于今年6月发布了Flash Player 9,开创了先河。 由于有了新的内部体系结构,Flash Player 9的运行速度比以前的版本快十倍。 Flash的编程语言ActionScript也获得了广泛的更新,这将有助于从其他语言进行迁移的开发人员感到宾至如归。 由于ECMAScript for XML(E4X),新功能包括强类型,正则表达式和对XML的本机支持。 Flash 9可在Windows和Mac OS X上运行,目前正在开发Linux播放器。

At its core, the Flex Framework comes with dozens of components, from basic lists and data grids to charts, layout systems, and media players. Additionally, Flex Data Services (FDS) allows your Flex application to interact with Java libraries on a server. It also provides facilities for data synchronization, messaging, and collaboration. And, unlike previous releases of Flex that required the developers to have the full version of Flex Data Services and cost thousands of dollars, the Flex 2 framework, compiler, and a command-line debugger can all be downloaded for free. Yes, you heard that right: the basic developer tools can be downloaded at no cost! It’s even possible to access a limited version of Flex Data Services for free.

Flex框架的核心是数十个组件,从基本列表和数据网格到图表,布局系统和媒体播放器。 此外,Flex Data Services(FDS)允许您的Flex应用程序与服务器上的Java库进行交互。 它还提供了用于数据同步,消息传递和协作的工具。 而且,不同于以前的Flex版本要求开发人员拥有完整版本的Flex Data Services并花费数千美元,Flex 2框架,编译器和命令行调试器都可以免费下载。 是的,您没听错:可以免费下载基本的开发人员工具! 甚至有可能免费访问Flex Data Services的受限版本。

For serious Flex development, you’ll probably want to use Flex Builder. This powerful development environment includes a drag-and-drop visual editor, enhanced debugging capabilities, and a full-featured code editor. It leverages the open source Eclipse IDE, which should be very familiar to Java developers. A healthy community has grown around Eclipse, resulting in the development of many cool plug-ins, including some that allow integration with version control systems like CVS or SourceSafe and others that provide support for many other programming languages. Despite being based on an open source tool, Flex Builder is not free, nor is it cheap (US $499, or US $749 if you include data visualization components). However, you can download a 30-day free trial version (or the Flex Builder plug-in, if you already have Eclipse installed), or use your own IDE instead.

对于认真的Flex开发,您可能需要使用Flex Builder 。 这个强大的开发环境包括一个拖放式可视化编辑器,增强的调试功能以及一个功能齐全的代码编辑器。 它利用Java开发人员应该非常熟悉的开源Eclipse IDE。 一个健康的社区围绕Eclipse成长,从而导致开发了许多很酷的插件,其中包括一些允许与版本控制系统(如CVS或SourceSafe)集成的插件,以及一些为许多其他编程语言提供支持的插件。 尽管使用的是开源工具,Flex Builder也不免费,也不便宜(499美元,如果包含数据可视化组件,则为749美元)。 但是,您可以下载30天的免费试用版(或Flex Builder插件,如果您已经安装了Eclipse),或者使用自己的IDE。

Before we start building our own application in this environment, let’s step back and take a look at what’s involved.

在此环境中开始构建自己的应用程序之前,让我们退后一步,看看其中涉及到什么。

Flex开发的工作原理 (How Flex Development Works)

Flex provides developers with more than one way to build an application or component. Our first foray into Flex will introduce MXML, a special markup language that was designed with application layout in mind. Creating an instance of a component in your application couldn’t get any easier than declaring it in MXML:

Flex为开发人员提供了多种方法来构建应用程序或组件。 我们对Flex的首次尝试将引入MXML,这是一种特殊的标记语言,其设计时考虑了应用程序的布局。 在应用程序中创建组件实例比在MXML中声明它容易得多:

<mx:Button id="myButton" label="Press Me!"/>

As you can see, the Button‘s properties are set right inside the tag. We’ve named this instance "myButton" and given it a label that says, "Press Me!" Setting the id allows us to reference this Button elsewhere in our code. Styles, such as colors or skins, and event handlers can be set in a similar way. For example, if you wanted to listen for a button click, you could call functions and run snippets of ActionScript code right inside the click property of the Button. We’ll see an example of this later, when we create our first Flex application.

如您所见, Button的属性设置在标签内部。 我们已将该实例命名为"myButton"并为其指定了标签“ Press Me!”。 设置id允许我们在代码的其他地方引用此Button 。 可以使用类似的方式来设置样式(例如颜色或皮肤)和事件处理程序。 例如,如果您想监听按钮的单击,则可以在Button的click属性内调用函数并运行ActionScript代码段。 当我们创建第一个Flex应用程序时,我们将在后面看到一个示例。

Thanks to the inherent hierarchy of XML, we can place components inside one another. Let’s put our Button inside a layout container — in this case, a Panel.

由于XML固有的层次结构,我们可以将组件彼此放置在一起。 让我们将Button放入布局容器中-在本例中为Panel

<mx:Panel>
 <mx:Button id="myButton" label="Press Me!"/>
</mx:Panel>

We’ve declared the Panel component with two tags this time. Containers in MXML work in the same way as they function in XHTML, where an element such as a paragraph includes an opening tag and a closing tag. Other components that appear inside these two tags will become children of the container.

这次我们用两个标签声明了Panel组件。 MXML中的容器的工作方式与它们在XHTML中的工作方式相同,其中诸如段落之类的元素包括一个开始标记和一个结束标记。 出现在这两个标签内的其他组件将成为容器的子代。

As you become more experienced with Flex, you’ll want to get down and dirty with pure ActionScript 3. Flex’s core components are written in this language, and the Flex documentation includes all sorts of information to help you write solid code that uses the same architecture. You’ll even discover that the source code for the core components comes with the Flex 2 compiler. What better place could there be to look for be

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值