

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、<p> 《動作腳本》,摘自自維基百科,</p><p><b> 自由的百科全書</b></p><p><b> 2009年5月10</b></p><p> 《ActionScript》</p><p> Designed by Gary Grossman</p>
2、;<p><b> 1998年9月</b></p><p><b> 英文譯文:</b></p><p><b> 動作腳本</b></p><p> ActionScript是 Macromedia(現(xiàn)已被Adobe收購)為其Flash產(chǎn)品開發(fā)的,最初是一種簡單的腳本語言,現(xiàn)在
3、最新版本3.0,是一種完全的面向對象的編程語言,功能強大,類庫豐富,語法類似JavaScript,多用于Flash互動性、娛樂性、實用性開發(fā),網(wǎng)頁制作和RIA應用程序開發(fā)。</p><p> ActionScript 是一種基于ECMAScript的腳本語言,可用于編寫Adobe Flash動畫和應用程序。 由于ActionScript和JavaScript都是基于ECMAScript語法的,理論上它們互相可以
4、很流暢地從一種語言翻譯到另一種。不過JavaScript的文檔對象模型(DOM)是以瀏覽器窗口,文檔和表單為主的,ActionScript的文檔對象模型(DOM)則以SWF格式動畫為主,可包括動畫,音頻,文字和事件處理。</p><p><b> 歷史 </b></p><p> 在Mac OS X 10.2操作系統(tǒng)上的Macromedia Flash MX專業(yè)版
5、里,這些代碼可以創(chuàng)建一個與MAC OS X啟動過程中看見的類似的動畫。ActionScript第一次以它目前的語法出現(xiàn)是Flash 5版本,這也是第一個完全可對Flash編程的版本。這個版本被命名為ActionScript1.0。Flash 6通過增加大量的內(nèi)置函數(shù)和對動畫元素更好的編程控制更進一步增強了編程環(huán)境的功能。Flash 7(MX 2004)引進了ActionScript2.0,它增加了強類型(strong typing)和面
6、向對象特征,如顯式類聲明, 繼承,接口和嚴格數(shù)據(jù)類型。ActionScript1.0和2.0使用相同的編譯形式編譯成Flash SWF文件(即Shockwave Flash files,或 'Small Web Format').</p><p><b> 時間表</b></p><p> Flash Player 2:第一個支持腳本的版本,包括控
7、制時間軸的gotoAndPlay, gotoAndStop, nextFrame和nextScene等動作。 </p><p> Flash Player 3:增強了載入外部SWF文件的基本腳本支持(loadMovie)。 </p><p> Flash Player 4:第一個完全實現(xiàn)腳本功能(稱為動作)的播放器。這些腳本擁有簡練的語法和對循環(huán),條件,變量和其它基本語言結構的支持。
8、</p><p> Flash Player 5:第一個擁有真正意義上的ActionScript的版本。依據(jù)ECMAScript并采用基于原型編程,并允許完全的 過程式編程和面向對象編程。 </p><p> Flash Player 6:增加了事件處理模型,并且支持switch。 </p><p> Flash Player 7: Flash Player
9、7 提供一些新特性如支持CSS顯示文本和增強顯示效果。 Macromedia Flash編譯器和Flash Player 7同時支持基于ECMAScript 4 Netscape Proposal的類編程語言ActionScript 2.0。不過ActionScript 2.0能交叉編譯成ActionScript 1.0的字節(jié)碼,因此它能運行于Flash Player 6。 </p><p> Flash Pl
10、ayer 8:增加用于運行時圖象數(shù)據(jù)控制和文件上傳的新類庫及APIs,ActionScript 2.0功能更為完善。 </p><p> Flash Player 8.5(計劃于2006春發(fā)布release版本,currently in public beta):增加ActionScript 3.0和一個稱為AVM2(ActionScript Virtual Machine 2)新的虛擬機,它可以與前版本AVM
11、1共存以便支持舊內(nèi)容。增強性能是該版本的主要目標。 </p><p> Flash Player 9 2007發(fā)表,這是adobe收購Macromedia后的第一個版本,并且也是Mac OS X上第一個Universal版本的Flash Player。[1] </p><p><b> 語言</b></p><p><b> 語
12、法</b></p><p> 在ActionScript 2.0 類、與函式館物件(如影片片段)可與類聯(lián)系在一起。類總寫在外在文件檔案內(nèi),并且這些文件必須有.as后綴。類是增設部分──對ActionScrip語言來說,可讓程式員自行開發(fā),雖然有許多內(nèi)建類譬如MovieClip類──可被用來動態(tài)地在屏幕上畫出向量──已經(jīng)滿足需求了。類檔案可用來使您編程更加容易,并且類檔案如果需要的話可在許多專案間轉移
13、。</p><p> Flash ActionScript實現(xiàn)的特點如下,JavaScript程式員也許感興趣:</p><p> 一切設計是異步的;callback是普遍存在的,但事件對象不存在。 </p><p> XML的實現(xiàn)從Flash 5便存在了。Flash可送和收XML,該項功能可用來透過網(wǎng)絡服務器創(chuàng)造網(wǎng)上多玩者游戲。 </p>&l
14、t;p> ActionScript 代碼常常直接寫在Flash開發(fā)環(huán)境。該環(huán)境提供參考、代碼提示和句法強調(diào)。原代碼常常與電影一起存在.fla檔案里。自外部文件檔透過#include語法導入ActionScript代碼也相當常見。在這種情況下,外部檔案也許被Flash集成開發(fā)環(huán)境內(nèi)建編譯器,或Motion Twin ActionScript2編譯器(MTASC)編譯。參見外部鏈接。</p><p><
15、b> 評論</b></p><p> 編程人員們說Macromedia ActionScript 2.0編譯器有點慢,常?;ê脦追昼姴啪幾g100個類,然而開放源碼編譯器MTASC可以利用;它快多了。 </p><p> ActionScript非常寬大的語法常常讓編程人員們皺眉,因為它常常讓不干凈代碼難以閱讀。在Flash里使用許多向量可能拖慢執(zhí)行許多應用程序的機器
16、的效能,因為Flash每幀每幀重畫每個向量。Flash 8引進了cacheAsBitmap 變量,它暫時把向量轉換到位圖,這種做法幫助降低了延滯。 </p><p> Flash的ActionScript VM傾向在觸發(fā)內(nèi)部的暫停處理前就非常快達到它的運算極限,特別在麥金塔版的Flash播放器上更嚴重。例如,簡單從1算到5000會威脅某些用戶Flash播放器的能力。 </p><p>
17、 在Flash 8里許多人不喜歡引入(import)某些類直到要用到那些類前最后一刻。不幸的是,ActionScript 3.0相當倚賴引入類,沒有導入撰寫腳本(scripting)實際上不太可能。 </p><p> .swf檔案格式挺容易反組譯,使它非常難以保持源代碼機密。 </p><p><b> 樣本</b></p><p>
18、ActionScript 2.0 樣本</p><p> 下面打印Hello World。值得注意的是這只能在整合環(huán)境下執(zhí)行,因為trace函式只有支援整合環(huán)境。</p><p> trace("Hello world!");</p><p> 下面代碼利用onMouseMove事件當鼠標移動時輸出現(xiàn)行鼠標位置。同樣的這只有在整合環(huán)境下執(zhí)行
19、。</p><p> onMouseMove = function () {</p><p> trace("X: "+_root._xmouse);</p><p> trace("Y: "+_root._ymouse);</p><p><b> };</b></
20、p><p> 這個較先進的范例創(chuàng)造一個包括數(shù)字與字串的陣列,并利用原形函式(prototype function)與函式遞歸給變量名num指定一個數(shù),給變量str指定一個字串。然后,利用MovieClip應用程序接口,文字區(qū)域被顯示在屏幕上,文字區(qū)域里頭寫入了變量值。</p><p> var my_Array:Array = new Array("Hello", &q
21、uot;ActionScript", 3, 7, 11, "Flash");</p><p> Array.prototype.pickNumber = function():Number {</p><p> var rand:Number = random(this.length);</p><p> return (typ
22、eof (this[rand]) == "number") ? this[rand] : this.pickNumber();</p><p><b> };</b></p><p> Array.prototype.pickString = function():String {</p><p> var rand
23、:Number = random(this.length);</p><p> return (typeof (this[rand]) == "string") ? this[rand] : this.pickString();</p><p><b> };</b></p><p> var num:Number =
24、 my_Array.pickNumber();</p><p> var str:String = my_Array.pickString();</p><p> _root.createTextField("txt", 1, 10, 10, 530, 390);</p><p> txt.text = "Array = &quo
25、t;+my_Array+"\nRandom Number = "+num+"\nRandom String = "+str;</p><p> ActionScript 3.0 樣本</p><p> 下面先進的Hello World程序目前需要在Flex 2.0公開Alpha測試版整合環(huán)境中編譯。</p><p><
26、;b> package {</b></p><p> import flash.display.TextField;</p><p> import flash.display.MovieClip;</p><p> import flash.filters.DropShadowFilter;</p><p> p
27、ublic class HelloWorld extends MovieClip {</p><p> public function HelloWorld() {</p><p> var shad:DropShadowFilter = new DropShadowFilter(2, 45, 0x000000, 25, 3, 3, 2, 2);</p><p>
28、; var txt:TextField = new TextField();</p><p> txt.textColor = 0xFFFFFF;</p><p> txt.filters = [shad];</p><p> txt.width = 120;</p><p> txt.x = Math.random()*300;&
29、lt;/p><p> txt.y = Math.random()*300;</p><p> txt.selectable = false;</p><p> txt.text = "Hello World! ["+Math.round(txt.x)+","+Math.round(txt.y)+"]";&
30、lt;/p><p> addChild(txt);</p><p><b> }</b></p><p><b> }</b></p><p><b> }</b></p><p><b> 英文原文:</b></p&g
31、t;<p> ActionScript</p><p> ActionScript is a scripting language based on ECMAScript. ActionScript is used primarily for the development of websites and software using the Adobe Flash Player platfor
32、m (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 l
33、anguage is now owned by Adobe (which acquired Macromedia in 2005). ActionScript was initially designed for con</p><p><b> History</b></p><p> ActionScript started as a scripting la
34、nguage for Macromedia's 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
35、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 "got
36、oAndPlay".</p><p> 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,
37、 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 .<
38、/p><p> Timeline by player</p><p> Flash Player 2: The first version with scripting support. Actions included gotoAndPlay, gotoAndStop, nextFrame and nextScene for timeline control. </p>&
39、lt;p> Flash Player 3: Expanded basic scripting support with the ability to load external SWFs (loadMovie). </p><p> Flash Player 4: First player with a full scripting implementation (called Actions). Th
40、e scripting was a flash based syntax and contained support for loops, conditionals, variables and other basic language constructs. </p><p> Flash Player 5: Included the first version of ActionScript. Used p
41、rototype-based programming based on ECMAScript, and allowed full procedural programming and object-oriented programming. </p><p> Flash Player 6: Added an event handling model, accessibility controls and su
42、pport for switch. The first version with support for the AMF and RTMP protocols which allowed for ondemand audio/video streaming. </p><p> Flash Player 7: Additions include CSS styling for text and support
43、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 Flas
44、h Player 6. </p><p> 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 an
45、d dropshadow. </p><p> 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 (ActionSc
46、ript 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 binar
47、y sockets, E4X XML parsing, full-screen mode and Regular Expressions were added. This is the firs</p><p> Flash Player 10 (initially called Astro): Added basic 3D manipulation, such as rotating on the X, Y,
48、 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 fram
49、e, 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</p><p> Timeline by Actio
50、nScript version</p><p> 2000–2003: ActionScript "1.0" With the release of Flash 5 in September 2000, the "actions" from Flash 4 were enhanced once more and named "ActionScript"
51、 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 standard's object model and many of its core data type
52、s. Local variables may be declared with the var statement, and user-defined functions with parameter passing and return values can a</p><p> 2003–2006: ActionScript 2.0 The next major revision of the langua
53、ge, 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
54、 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</
55、p><p> 2006–today: 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
56、 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
57、 3.0 added limited support for hardware acceleration ( DirectX, OpenGL ).</p><p> The update to the language introduced several new features:</p><p> Compile-time and runtime type checking—typ
58、e information exists at both compile-time and runtime. </p><p> Improved performance from a class-based inheritance system separate from the prototype-based inheritance system. </p><p> Suppor
59、t for packages, namespaces, and regular expressions. </p><p> Compiles to an entirely new type of bytecode, incompatible with ActionScript 1.0 and 2.0 bytecode. </p><p> Revised Flash Player A
60、PI, organized into packages. </p><p> Unified event handling system based on the DOM event handling standard. </p><p> Integration of ECMAScript for XML (E4X) for purposes of XML processing. &
61、lt;/p><p> Direct access to the Flash runtime display list for complete control of what gets displayed at runtime. </p><p> Completely conforming implementation of the ECMAScript fourth edition d
62、raft specification. </p><p> Flash Lite</p><p> Flash Lite 1.0: Flash Lite is the Flash technology specifically developed for mobile phones and consumer electronics devices. Supports Flash 4 A
63、ctionScript. </p><p> Flash Lite 1.1: Flash 4 ActionScript support and additional device APIs added. </p><p> Flash Lite 2.0 and 2.1: Added support for Flash 7 ActionScript 2.0 and some additi
64、onal fscommand2 API. </p><p> Flash Lite 3: Added support for Flash 8 ActionScript 2.0 and also FLV video playback. </p><p><b> Syntax</b></p><p> ActionScript code i
65、s 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.</p><p> ActionScript 2.0</p><p> The foll
66、owing 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 parameter is set to the "Hello
67、, world!" string, and it is automatically displayed in the player:</p><p> createTextField("greet", 0, 0, 0, 100, 100);</p><p> greet.text = "Hello, world";</p>
68、<p> When writing external ActionScript 2.0 class files the above example could be written in a file named Greeter.as as following.</p><p> class com.example.Greeter extends MovieClip</p><
69、p><b> {</b></p><p> public function Greeter() {}</p><p> public function onLoad() :Void</p><p><b> {</b></p><p> var txtHello:TextField
70、= this.createTextField("txtHello", 0, 0, 0, 100, 100.);</p><p> txtHello.text = "Hello, world";</p><p><b> }</b></p><p><b> }</b></
71、p><p> ActionScript 3.0</p><p> ActionScript 3.0 has a similar syntax to ActionScript 2.0 but a different set of APIs for creating objects. Compare the script below to the previous ActionScript 2
72、.0 version:</p><p> var greet:TextField = new TextField();</p><p> greet.text = "Hello World";</p><p> this.addChild(greet);</p><p> Minimal ActionScript
73、3.0 programs may be somewhat larger and more complicated due to the increased separation of the programming language and the Flash IDE.</p><p> Presume the following file to be Greeter.as:</p><p&
74、gt; package com.example</p><p><b> {</b></p><p> import flash.text.TextField;</p><p> import flash.display.Sprite;</p><p> public class Greeter extends
75、 Sprite</p><p><b> {</b></p><p> public function Greeter()</p><p><b> {</b></p><p> var txtHello:TextField = new TextField();</p><
76、;p> txtHello.text = "Hello World";</p><p> addChild(txtHello);</p><p><b> }</b></p><p><b> }</b></p><p><b> }</b>&
77、lt;/p><p> (See also: Sprite)</p><p> Finally, an example of using ActionScript when developing Flex applications, again presuming the following content to be in a file named Greeter.as:</p>
78、;<p><b> package</b></p><p><b> {</b></p><p> public class Greeter</p><p><b> {</b></p><p> public static function sayHe
79、llo():String</p><p><b> {</b></p><p> var greet:String = "Hello, world!";</p><p> return greet;</p><p><b> }</b></p><p&
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 眾賞文庫僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 計算機專業(yè)畢業(yè)設計文獻翻譯
- 計算機專業(yè)畢業(yè)設計外文文獻翻譯部分
- 計算機專業(yè)畢業(yè)設計外文翻譯
- 計算機專業(yè)畢業(yè)設計-外文翻譯
- 計算機專業(yè)畢業(yè)設計外文翻譯27
- 計算機專業(yè)畢業(yè)設計外文翻譯--internet
- 計算機專業(yè)外文翻譯(文獻翻譯)
- 計算機相關專業(yè)畢業(yè)設計電阻式觸摸屏--文獻翻譯
- 計算機專業(yè)畢業(yè)設計外文資料翻譯3
- 計算機專業(yè)畢業(yè)設計-外文翻譯--matlab 介紹
- 計算機專業(yè)畢業(yè)設計外文文獻及譯文
- 計算機專業(yè)外文翻譯(文獻翻譯)
- 130計算機專業(yè)畢業(yè)設計外文文獻翻譯:介紹java web開發(fā)
- 計算機畢業(yè)設計外文翻譯
- 計算機專業(yè)畢業(yè)設計文獻翻譯--一切都是對象
- 計算機專業(yè)畢業(yè)設計外文翻譯--jsp內(nèi)置對象
- 計算機專業(yè)畢業(yè)設計外文翻譯--數(shù)據(jù)庫
- 計算機專業(yè)畢業(yè)設計(論文)外文翻譯2篇
- 計算機專業(yè)畢業(yè)設計外文翻譯--ds1820
- 計算機專業(yè)畢業(yè)設計題目大全
評論
0/150
提交評論