已阅读5页,还剩5页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
动作脚本,摘自自维基百科,自由的百科全书2009年5月10actionscriptdesigned by gary grossman1998年9月 英文译文: 动作脚本actionscript是 macromedia(现已被adobe收购)为其flash产品开发的,最初是一种简单的脚本语言,现在最新版本3.0,是一种完全的面向对象的编程语言,功能强大,类库丰富,语法类似javascript,多用于flash互动性、娱乐性、实用性开发,网页制作和ria应用程序开发。actionscript 是一种基于ecmascript的脚本语言,可用于编写adobe flash动画和应用程序。 由于actionscript和javascript都是基于ecmascript语法的,理论上它们互相可以很流畅地从一种语言翻译到另一种。不过javascript的文档对象模型(dom)是以浏览器窗口,文档和表单为主的,actionscript的文档对象模型(dom)则以swf格式动画为主,可包括动画,音频,文字和事件处理。 历史 在mac os x 10.2操作系统上的macromedia flash mx专业版里,这些代码可以创建一个与mac os x启动过程中看见的类似的动画。actionscript第一次以它目前的语法出现是flash 5版本,这也是第一个完全可对flash编程的版本。这个版本被命名为actionscript1.0。flash 6通过增加大量的内置函数和对动画元素更好的编程控制更进一步增强了编程环境的功能。flash 7(mx 2004)引进了actionscript2.0,它增加了强类型(strong typing)和面向对象特征,如显式类声明, 继承,接口和严格数据类型。actionscript1.0和2.0使用相同的编译形式编译成flash swf文件(即shockwave flash files,或 small web format).时间表flash player 2:第一个支持脚本的版本,包括控制时间轴的gotoandplay, gotoandstop, nextframe和nextscene等动作。 flash player 3:增强了载入外部swf文件的基本脚本支持(loadmovie)。 flash player 4:第一个完全实现脚本功能(称为动作)的播放器。这些脚本拥有简练的语法和对循环,条件,变量和其它基本语言结构的支持。 flash player 5:第一个拥有真正意义上的actionscript的版本。依据ecmascript并采用基于原型编程,并允许完全的 过程式编程和面向对象编程。 flash player 6:增加了事件处理模型,并且支持switch。 flash player 7: flash player 7 提供一些新特性如支持css显示文本和增强显示效果。 macromedia flash编译器和flash player 7同时支持基于ecmascript 4 netscape proposal的类编程语言actionscript 2.0。不过actionscript 2.0能交叉编译成actionscript 1.0的字节码,因此它能运行于flash player 6。 flash player 8:增加用于运行时图象数据控制和文件上传的新类库及apis,actionscript 2.0功能更为完善。 flash player 8.5(计划于2006春发布release版本,currently in public beta):增加actionscript 3.0和一个称为avm2(actionscript virtual machine 2)新的虚拟机,它可以与前版本avm1共存以便支持旧内容。增强性能是该版本的主要目标。 flash player 9 2007发表,这是adobe收购macromedia后的第一个版本,并且也是mac os x上第一个universal版本的flash player。1 语言语法在actionscript 2.0 类、与函式馆物件(如影片片段)可与类联系在一起。类总写在外在文件档案内,并且这些文件必须有.as后缀。类是增设部分对actionscrip语言来说,可让程式员自行开发,虽然有许多内建类譬如movieclip类可被用来动态地在屏幕上画出向量已经满足需求了。类档案可用来使您编程更加容易,并且类档案如果需要的话可在许多专案间转移。flash actionscript实现的特点如下,javascript程式员也许感兴趣:一切设计是异步的;callback是普遍存在的,但事件对象不存在。 xml的实现从flash 5便存在了。flash可送和收xml,该项功能可用来透过网络服务器创造网上多玩者游戏。 actionscript 代码常常直接写在flash开发环境。该环境提供参考、代码提示和句法强调。原代码常常与电影一起存在.fla档案里。自外部文件档透过#include语法导入actionscript代码也相当常见。在这种情况下,外部档案也许被flash集成开发环境内建编译器,或motion twin actionscript2编译器(mtasc)编译。参见外部链接。评论编程人员们说macromedia actionscript 2.0编译器有点慢,常常花好几分钟才编译100个类,然而开放源码编译器mtasc可以利用;它快多了。 actionscript非常宽大的语法常常让编程人员们皱眉,因为它常常让不干净代码难以阅读。在flash里使用许多向量可能拖慢执行许多应用程序的机器的效能,因为flash每帧每帧重画每个向量。flash 8引进了cacheasbitmap 变量,它暂时把向量转换到位图,这种做法帮助降低了延滞。 flash的actionscript vm倾向在触发内部的暂停处理前就非常快达到它的运算极限,特别在麦金塔版的flash播放器上更严重。例如,简单从1算到5000会威胁某些用户flash播放器的能力。 在flash 8里许多人不喜欢引入(import)某些类直到要用到那些类前最后一刻。不幸的是,actionscript 3.0相当倚赖引入类,没有导入撰写脚本(scripting)实际上不太可能。 .swf档案格式挺容易反组译,使它非常难以保持源代码机密。 样本actionscript 2.0 样本下面打印hello world。值得注意的是这只能在整合环境下执行,因为trace函式只有支援整合环境。trace(hello world!);下面代码利用onmousemove事件当鼠标移动时输出现行鼠标位置。同样的这只有在整合环境下执行。onmousemove = function () trace(x: +_root._xmouse); trace(y: +_root._ymouse);这个较先进的范例创造一个包括数字与字串的阵列,并利用原形函式(prototype function)与函式递归给变量名num指定一个数,给变量str指定一个字串。然后,利用movieclip应用程序接口,文字区域被显示在屏幕上,文字区域里头写入了变量值。var my_array:array = new array(hello, actionscript, 3, 7, 11, flash);atotype.picknumber = function():number var rand:number = random(this.length); return (typeof (thisrand) = number) ? thisrand : this.picknumber();atotype.pickstring = function():string var rand:number = random(this.length); return (typeof (thisrand) = string) ? thisrand : this.pickstring();var num:number = my_array.picknumber();var str:string = my_array.pickstring();_root.createtextfield(txt, 1, 10, 10, 530, 390);txt.text = array = +my_array+nrandom number = +num+nrandom string = +str;actionscript 3.0 样本下面先进的hello world程序目前需要在flex 2.0公开alpha测试版整合环境中编译。package import flash.display.textfield; import flash.display.movieclip; import flash.filters.dropshadowfilter; public class helloworld extends movieclip public function helloworld() var shad:dropshadowfilter = new dropshadowfilter(2, 45, 0x000000, 25, 3, 3, 2, 2); var txt:textfield = new textfield(); txt.textcolor = 0xffffff; txt.filters = shad; txt.width = 120; txt.x = math.random()*300; txt.y = math.random()*300; txt.selectable = false; txt.text = hello world! +math.round(txt.x)+,+math.round(txt.y)+; addchild(txt); 英文原文:actionscriptactionscript is a scripting language based on ecmascript. actionscript is used primarily for the development of websites and software using the adobe flash player platform (in the form of swf files embedded into web pages), but is also used in some database applications (such as alpha five), and in basic robotics, as with the make controller kit. originally developed by macromedia, the language is now owned by adobe (which acquired macromedia in 2005). actionscript was initially designed for controlling simple 2d vector animations made in adobe flash (formerly macromedia flash). later versions added functionality allowing for the creation of web-based games and rich internet applications with streaming media (such as video and audio).historyactionscript started as a scripting language for macromedias flash authoring tool, now developed by adobe systems as adobe flash. the first three versions of the flash authoring tool provided limited interactivity features. early flash developers could attach a simple command, called an action, to a button or a frame. the set of actions was basic navigation controls, with commands such as play, stop, geturl, and gotoandplay.with the release of flash 4 in 1999, this simple set of actions became a small scripting language. new capabilities introduced for flash 4 included variables, expressions, operators, if statements, and loops. although referred to internally as actionscript, the flash 4 user manual and marketing documents continued to use the term actions to describe this set of commands .timeline by playerflash player 2: the first version with scripting support. actions included gotoandplay, gotoandstop, nextframe and nextscene for timeline control. flash player 3: expanded basic scripting support with the ability to load external swfs (loadmovie). flash player 4: first player with a full scripting implementation (called actions). the scripting was a flash based syntax and contained support for loops, conditionals, variables and other basic language constructs. flash player 5: included the first version of actionscript. used prototype-based programming based on ecmascript, and allowed full procedural programming and object-oriented programming. flash player 6: added an event handling model, accessibility controls and support for switch. the first version with support for the amf and rtmp protocols which allowed for ondemand audio/video streaming. flash player 7: additions include css styling for text and support for actionscript 2.0, a programming language based on the ecmascript 4 netscape proposal with class-based inheritance. however, actionscript 2.0 can cross compile to actionscript 1.0 byte-code, so that it can run in flash player 6. flash player 8: further extended actionscript 1/actionscript 2 by adding new class libraries with apis for controlling bitmap data at run-time, file uploads and live filters for blur and dropshadow. example of actionscript 2.0 running on macromedia flash 8.flash player 9 (initially called 8.5): added actionscript 3.0 with the advent of a new virtual machine, called avm2 (actionscript virtual machine 2), which coexists with the previous avm1 needed to support legacy content. performance increases were a major objective for this release of the player including a new jit compiler. support for binary sockets, e4x xml parsing, full-screen mode and regular expressions were added. this is the first release of the player to be titled adobe flash player. flash player 10 (initially called astro): added basic 3d manipulation, such as rotating on the x, y, and z axis, and a 3d drawing api. ability to create custom filters using adobe pixel bender. several visual processing tasks are now offloaded to the gpu which gives a noticeable decrease to rendering time for each frame, resulting in higher frame rates, especially with h.264 video. there is a new sound api which allows for custom creation of audio in flash, something that has never been possible before. 2 timeline by actionscript version20002003: actionscript 1.0 with the release of flash 5 in september 2000, the actions from flash 4 were enhanced once more and named actionscript for the first time.3 this was the first version of actionscript with influences from javascript and the ecma-262 (third edition) standard, supporting the said standards object model and many of its core data types. local variables may be declared with the var statement, and user-defined functions with parameter passing and return values can also be created. notably, actionscript could now also be typed with a text editor rather than being assembled by choosing actions from drop-down lists and dialog box controls. with the next release of its authoring tool, flash mx, and its corresponding player, flash player 6, the language remained essentially unchanged; there were only minor changes, such as the addition of the switch statement and the strict equality (=) operator, which brought it closer to being ecma-262-compliant. two important features of actionscript that distinguish it from later versions are its loose type system and its reliance on prototype-based inheritance. loose typing refers to the ability of a variable to hold any type of data. this allows for rapid script development and is particularly well-suited for small-scale scripting projects. prototype-based inheritance is the actionscript 1.0 mechanism for code reuse and object-oriented programming. instead of a class keyword that defines common characteristics of a class, actionscript 1.0 uses a special object that serves as a prototype for a class of objects. all common characteristics of a class are defined in the classs prototype object and every instance of that class contains a link to that prototype object.20032006: actionscript 2.0 the next major revision of the language, actionscript 2.0, was introduced in september 2003 with the release of flash mx 2004 and its corresponding player, flash player 7. in response to user demand for a language better equipped for larger and more complex applications, actionscript 2.0 featured compile-time type checking and class-based syntax, such as the keywords class and extends. (while this allowed for a more structured object-oriented programming approach, the code would still be compiled to actionscript 1.0 bytecode, allowing it to be used on the preceding flash player 6 as well. in other words, the class-based inheritance syntax was a layer on top of the existing prototype-based system.) with actionscript 2.0, developers could constrain variables to a specific type by adding a type annotation so that type mismatch errors could be found at compile-time. actionscript 2.0 also introduced class-based inheritance syntax so that developers could create classes and interfaces, much as they would in class-based languages such as java and c+. this version conformed partially to the ecmascript fourth edition draft specification.2006today: actionscript 3.0 in june 2006, actionscript 3.0 debuted with adobe flex 2.0 and its corresponding player, flash player 9. actionscript 3.0 was a fundamental restructuring of the language, so much so that it uses an entirely different virtual machine. flash player 9 contains two virtual machines, avm1 for code written in actionscript 1.0 and 2.0, and avm2 for content written in actionscript 3.0. actionscript 3.0 added limited support for hardware acceleration ( directx, opengl ).the update to the language introduced several new features:compile-time and runtime type checkingtype information exists at both compile-time and runtime. improved performance from a class-based inheritance system separate from the prototype-based inheritance system. support for packages, namespaces, and regular expressions. compiles to an entirely new type of bytecode, incompatible with actionscript 1.0 and 2.0 bytecode. revised flash player api, organized into packages. unified event handling system based on the dom event handling standard. integration of ecmascript for xml (e4x) for purposes of xml processing. direct access to the flash runtime display list for complete control of what gets displayed at runtime. completely conforming implementation of the ecmascript fourth edition draft specification. flash liteflash lite 1.0: flash lite is the flash technology specifically developed for mobile phones and consumer electronics devices. supports flash 4 actionscript. flash lite 1.1: flash 4 actionscript support and additional device apis added. flash lite 2.0 and 2.1: added support for flash 7 actionscript 2.0 and some additional fscommand2 api. flash lite 3: added support for flash 8 actionscript 2.0 and also flv video playback. syntaxactionscript code is free form and thus may be created with whichever amount or style of whitespace that the author desires. the basic syntax is derived from ecmascript.actionscript 2.0the following code, which works in any compliant player, creates a text field at depth 0, at position (0, 0) on the screen (measured in pixels), that is 100 pixels wide and high. then the text
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 餐饮中餐服务培训
- 餐厅迎宾技能培训
- 2026校招:vivo题库及答案
- 餐厅管理学知识
- 2026中考冲刺动员大会校长发言稿:百日冲刺我们陪你不负期许
- 事业单位固定资产管理办法
- 2025-2026学年南宁市数学二年级第二学期期末质量检测试题含解析
- 企业合同管理办法
- 餐厅厅面员工培训
- 关于网络与信息安全工作落实情况的报告
- 2026年春期人教版二年级下册数学全册教案(核心素养教案)
- 2026年广东省湛江市高三一模高考数学试卷试题(答案详解)
- 水利工程地质勘察规范(标准版)
- 2026年农业科技行业智能灌溉系统报告及未来农业创新发展趋势报告
- 儿科雾化治疗的护理沟通技巧
- 译林版英语六年级上册单词默写本(正乱序英汉互译)含答案
- 购物商城管理系统
- 中国中煤能源集团有限公司图克绿色低碳产业示范园区规划-高质量打造鄂尔多斯世界级现代煤化工产业示范区关键核心区
- 2026年高考地理压轴训练卷1
- 2026考公省考云南试题及答案
- 蔬菜净料率行业标准参照表
评论
0/150
提交评论