- 浏览: 350867 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
lliiqiang:
在功能上,由于flex不支持加载外来的类的反射机制,所以可以通 ...
Flex Module专题 -
迪伦少校:
工程报错呢?。。
关于DEGRAFA的简介 -
chwnchwn:
不错的东西
关于DEGRAFA的简介 -
lorry1113:
学习了,多谢!!!!
重写FLEX组件 -
cuixuxucui:
var str:String = "";v ...
AS3 Array学习笔记
原文链接:http://graphics-geek.blogspot.com/2008_02_01_archive.html
A comment on my previous posting asked for some explanation of what Flex is and how it relates to Flash.
I'm still intending on posting some technical content here and going over some sample code, but hey - I'm Flexible.
I was sort of assuming that everyone had heard of Flex and knew something about it. But since I'm new to the platform myself, and since I intend this blog to be for relative newcomers to the platform (at least for now, since that's where I'm at), it seems reasonable to define some terms. Here is my understanding of how these various Adobe products and platforms relate to each other. If I get whacked from someone in marketing, I'll replace them with something more correct, but I think this will do for now.
ActionScript
ActionScript is the programming language used to program Flash applications. The current version of the language is ActionScript3, which is based on ECMAScript (read: JavaScript), and should be quite familiar to most web programmers because of its similarity to JavaScript. ActionScript is more type-safe that JavaScript in general (or at least that's my impression from using it in the Flex environment); you need to declare most variables as having specific types at compile time. The base syntax is actually not too unlike Java. I've found the transition easy overall, although I still write my variable declarations backwards out of habit and then go back and fix them when the compiler pukes on my code. For example, the following declaration in Java:
Object blah;
would be writtin in ActionScript as:
var blah:Object;
I should write a macro in the IDE to do the switch for me, since I seem to have a hard time twisting my brain around after all this time to do it correctly.
Flash
Flash is a graphical library and runtime that enables animated graphics applications. There is an authoring tool for creating Flash content, a language for programming Flash applications (ActionScript3), a class library of graphics and other useful objects, and a VM that enables Flash applications to perform well. From the start, Flash was about creating animations, and the tools and libraries for Flash all reflect that time-based model; the Stage, MovieClip objects, and frame rates are all part of a normal Flash application.
The rendering in Flash takes place via a "display list" (also known as a scene graph, or retained-mode graphics). Instead of issuing direct rendering calls in your code which get executed immediately (like they do in immediate-mode APIs such as Java 2D), you place rendering requests on a display list which gets processed and displayed which the next frame is rendered. These requests then stay on that display list until removed.
The use of a scene graph is a subtle point, and perhaps one that most application designers couldn't frankly give a toss about. But it ends up being important to Flash and Flex developers, as it's important to understand what is being put on the display list and when that display list needs to be cleared and repopulated with other rendering requests instead.
For example, if you put the following rendering calls into the display list of a Flash object (where graphics is the graphics context of a Flash display object):
graphics.moveTo(0, 0);
graphics.lineTo(100, 100);
then you will get a line on the screen from (wait for it...) (0, 0) to (100, 100). Suppose you later want to move the line to be from (50, 50) to (150, 100). If you made these calls to the graphics object:
graphics.moveTo(50, 50);
graphics.lineTo(150, 100);
and ran your application, you would see two lines on the screen. You didn't actually change the line's position; instead, you simply added another line to the display list. The typical way to get what you want is to recreate the display list from scratch by clearing it first, and then add in the rendering calls you want:
graphics.clear();
graphics.moveTo(50, 50);
graphics.lineTo(150, 100);
Flex
Flex is a GUI toolkit library that sits on top of the Flash library and runtime, much like Swing sits on top of Java 2D (for the Java folks in the audience). The addition of Flex did a few things to improve (at least for folks like me) the programming experience of Flash applications:
-
GUI components: Prior to Flex, most Flash applications brewed their own components (buttons, etc.), which meant more work for the developer, less consistency between applications, and potentially buggy or unpredictable behavior. Who here has run across bizarre implementations of scrollbars in Flash applications that didn't look or behave at all like the scroll bars we know and love? Flex brings uniformity and functionality to this previously, er, more chaotic space.
-
Programming model: As I alluded to before, the programming model of Flash is, well, different than most GUI developers might expect. Thinking about an enterprise UI in terms of MovieClips, frames, and display lists is, well, different. Flex abstracts all of that away and allows developers to write GUI applications for Flash in a much more traditional way. A button control is a button control, with events, skins, states, and so on; it's not a MovieClip added to a Stage or anything so unusual (at least to me, but maybe I just have Stage fright).
-
Declarative programming: Flex also introduced the MXML language for declarative programming of applications. This XML-based language allows programmers (and design tools) to create static code that tells Flex how the UI should be layed out, and saves the actual dynamic programming logic via ActionScript for things that cannot be declared statically. There are various advantages to this model (from what I've seen so far): clear XML code that sets up the GUI briefly (as opposed to lots of code to do the same task), a logical hierarchy of XML tags that reflect the parentage of GUI containers and components, and interaction with design tools for ongoing creation and editing of the GUI in a WYSIWYG builder (such as the one in FlexBuilder). It's pretty cool to be able to go in and out of design mode, hand-coding stuff where appropriate, and dragging and dropping other things when possible. The fact that the GUI layout is persisted in XML means that the builder tool can handle edits much better than approaches that use actual code behind the scenes (typically, the code is not allowed to be edited or if you do edit it you probably cannot get the tool to read it in again).
Given all of these advantages and advances of Flex, GUI programmers should now find it much easier to write real, full, robust GUI applications that run on the Flash platform.
The output of a Flex build is simply a SWF file (the type of file that the Flash player will run); it ends up just being another Flash application. But inside of that application is the set of Flex components and capabilities used in your application, which then translate into Flash rendering.
The Flex SDK is free and open sourced; you can write Flex applications, compile them, and ship them all for free.
FlexBuilder
This IDE (a plugin for the Eclipse platform) is optional - you can use the Flex SDK for free as a command-line compiler, using whatever IDEs and code editors you want. The FlexBuilder tool does cost money, but gives you some advantages over hand-coded Flex applications, such as the GUI builder I mentioned above as well as all of the code editing features you would expect for both ActionScript and MXML (code hinting, and so on).
AIR
Think of Adobe AIR as the packaging of both web applications (HTML/JavaScript) and Flex/Flash applications for the desktop. Flash was written originally for the browser, and Flash content is predominantly browser-based today. Although you can run SWF files in a standalone SWF player, traditional Flash applications are really intended for use in web browsers. The same goes for Flex applications, since they are essentially Flash applications with more built-in capabilities.
But what if your users want to run your application offline? Or what if they want access to their local filesystem, a feature that browser applications typically don't allow because of security restrictions?
AIR enables all of this; it allows applications to be installed on the local operating system and accessed from the desktop just like the other applications that the desktop user runs. AIR applications can still access online information, in fact that is still an important model for these rich applications, but they can also run offline when appropriate or necessary.
AIR also bundles in more capabilities that are not currently a part of the Flash or Flex platform, such as a full HTML/JavaScript rendering engine. So even if you're a web developer, just writing AJAX applications with HTML and JavaScript, you can use AIR to deploy these applications to your user's local desktop.
BlazeDS, LiveCycle, etc.
I think I'll leave these product terms for another day. There's a host of Flex-related products and capabilities for the back-end. But frankly, I'm still figuring out the stuff on the client, and I'd really rather stick to what I know on this blog....
发表评论
-
白名单屏蔽字 unicode字符范围
2016-07-05 16:58 831(_word.unicode >= 0x2001 ... -
flash textfiled换行 以及\r和\n区别
2016-06-20 15:11 1934flash.text.TextField.wordWrap ... -
flash 字体
2016-05-20 17:35 7461.FTE和TLF的关系 http://zengr ... -
Flex Date对象与UTC之间的关系
2013-08-07 14:16 2373转自 Flex Date对象与UTC ... -
as3 数据结构array,object,dictionary用哪个
2011-12-29 16:43 4415今天在处理背包物品时,考虑是用Array还是dictionar ... -
CS5 中禁用SimpleButton
2011-12-09 11:48 1909需要在CS5中对一个SimpleButton设置禁用效果,即不 ... -
Event.FRAME_CONSTRUCTED
2011-12-07 19:07 2142_oPBox是个MovieClip,共3帧,其中第1帧有 ... -
使用拼接的属性来访问Object
2011-11-28 15:58 10961.VO:Objectt有这些属性: public ... -
ShareObject简记
2011-10-25 18:58 1052引用: _soundSO = Shared ... -
字符集学习笔记(二)
2011-10-21 14:08 1571参考http://www.discuz.net/thre ... -
字符集学习笔记(一)
2011-10-20 17:17 1585摘自http://bbs.9ria.co ... -
使用AS3帧代码控制动画
2011-10-17 14:26 3950美术同事出了一个资源,大致是这样的:四个角色形象动画,聚在一个 ... -
flash cs将一个MC变成BUTTON
2011-09-15 16:50 1822在FLASH CS中,设置一个MC的三帧名字分别为 ... -
flash中的in关键字
2011-09-08 18:10 1325in这个关键字挺有意思的: package { ... -
VerifyError: Error #1024: 发生堆栈下溢
2011-08-26 16:14 4605今天出现了奇怪的问题,RELEASE版本的背包操作总是报Ver ... -
TextField的高宽autosize
2011-08-17 14:25 3382var t_name:TextField = new Text ... -
FLASH注册点与中心点(转)
2011-08-16 10:23 4801http://space.flash8.net/space/? ... -
flashbuilder不同版本共用工作空间的问题
2011-08-02 13:36 2450今天因为项目需要,安装了FB4.5,当然原来的FB4.0没舍得 ... -
flashplayer内存管理
2011-07-29 11:18 4419参考Flash务实主义(五)——AS3的垃圾回收 ... -
从SVN上的FD项目上,构建FB项目
2011-07-28 15:18 3681说一下概况: 项目是一个FD(FlashDevelop ...
相关推荐
- **定义与历史**:ActionScript是一种面向对象的脚本语言,主要用于增强Adobe Flash Player和Adobe AIR中的交互性和功能。它最初由Macromedia公司开发,后被Adobe公司收购。ActionScript经历了三个主要版本的发展:...
标题“使用FlexBuilder3制作并导出AIR1.0正式版应用”涉及到的是Adobe Flex Builder 3这款开发工具,以及Adobe Integrated Runtime (AIR) 1.0版本的应用程序开发过程。Flex Builder 3是一款基于Eclipse的IDE,专门...
Flex Air是Flex框架的一部分,它扩展了Flash Player的功能,让开发者能够利用ActionScript 3.0编程语言和Flex组件库来创建桌面应用。通过Air SDK,开发者可以访问操作系统资源,如文件系统、打印机和网络,实现更...
《flash+flex+air移动开发入门经典——适用于android、ios和blackberry》 第1章 flash、flex和air简介 1 1.1 adobe flash 1 1.2 actionscript 3.0 2 1.2.1 ecmascript 2 1.2.2 关键概念 3 1.3 flex框架 11 ...
Flex是基于MXML和ActionScript的开源框架,主要用于构建用户界面,而ActionScript是Adobe Flash Player和Adobe AIR平台上的编程语言,它是Flex开发的核心。 ActionScript起源于早期的Flash动画脚本,随着时间的推移...
同时,Flex应用运行在Flash Player或Adobe AIR上,这使得它们可以在多个平台上运行,包括Web浏览器和桌面环境。 2. **MXML和ActionScript**:Flex 4引入了MXML和ActionScript的混合编程模型,MXML用于声明式定义...
Flex Builder 4,也被称为Flash Builder 4,是一款由Adobe公司开发的专业集成开发环境(IDE),主要用于构建富互联网应用程序(RIA)。它基于Eclipse平台,为开发者提供了强大的工具集,以便于使用ActionScript 3和...
它基于ActionScript,一个面向对象的脚本语言,与Flash Player或Adobe AIR(Adobe Integrated Runtime)紧密结合,允许开发者创建动态、响应式的网络应用。 在Flex Builder中,你可以找到一系列功能,包括代码编辑...
Flex Air音乐播放器源码是基于Adobe Flex Builder 3开发的一款应用程序,主要使用ActionScript编程语言,这使得它能够在Adobe AIR(Adobe Integrated Runtime)平台上运行。Adobe Flex是用于构建富互联网应用程序...
它是基于Eclipse平台构建的,提供了丰富的工具集,支持ActionScript编程、MXML布局以及与Flash Player和Adobe AIR的交互。在Flex开发过程中,日志记录是调试和问题排查的重要环节,因此了解如何在Flex Builder中设置...
5. **Flex Builder**:虽然Flex SDK是免费的,但Adobe还提供了一个集成开发环境(IDE),即Flex Builder(现在称为Adobe Flash Builder),它为开发者提供了更友好的开发体验,包括代码提示、调试工具和项目管理功能...
Adobe Flash Builder 4是一款由Adobe公司开发的集成开发环境,专门用于Flex和ActionScript应用的快速开发。该软件最初于2010年5月6日更新,提供了丰富的功能,旨在帮助开发者高效地设计、编码、调试和优化富互联网...
FlexBuilder 3是一款由Adobe公司推出的集成开发环境(IDE),专为构建富互联网应用程序(RIA)而设计,尤其是基于Adobe Flash Player和Adobe AIR的应用。这个IDE是基于Eclipse平台,提供了一整套工具来帮助开发者...
Adobe Flex Builder 3.0是Adobe公司推出的一款强大的集成开发环境(IDE),专门用于构建富互联网应用程序(RIA),特别是基于Adobe Flash Player和Adobe AIR的应用。本教程将深入讲解Flex Builder 3.0的各个方面,...
本教程首先会介绍Flex SDK和Adobe Flash Builder等开发工具的安装与配置,这对于初学者来说是必不可少的基础知识。接着,它会深入讲解Flex编程基础,包括ActionScript语言的关键概念,如变量、数据类型、控制结构...
开发者可以使用Flex Builder(即现在的Flash Builder)或IntelliJ IDEA等集成开发环境,或者直接通过命令行进行打包操作。 3. **Flex Compiler**:在Air打包过程中,Flex Compiler将MXML和ActionScript代码转换为...
3.0版本引入了改进的代码提示、性能提升和对Flash Player及 AIR 平台的更好支持。 整合MyEclipse与Flex Builder的目的在于创建一个统一的工作流,使得开发者可以在同一环境下进行Flex前端和Java后端的开发,减少在...
在开发Flash游戏的过程中,FLEX和ActionScript是两个至关重要的技术。FLEX是一个开源的、基于MXML和ActionScript的框架,主要用于构建富互联网应用程序(RIA),而ActionScript是Adobe Flash平台的核心编程语言,...