# ActionScript

**ActionScript**是一种基于[ECMAScript](https://www.edgepedia.org/zh/ecmascript)的编程语言，在ActionScript虚拟机（AVM）中执行，AVM作为[Adobe Flash Player](https://www.edgepedia.org/zh/adobe-flash-player)和[Adobe AIR](https://www.edgepedia.org/zh/adobe-air)运行时的一部分一同发布。ActionScript代码被编译为字节码，嵌入SWF文件中，在AVM中执行。<sup>[1](https://help.adobe.com/en_US/as3/learn/as3_learning.pdf)</sup> ActionScript 3.0基于ECMAScript，符合ECMA-262第三版语言规范。<sup>[2](https://help.adobe.com/en_US/as3/components/flash_as3_components_help.pdf)</sup>

| 关键事实 | 详情 |
|---|---|
| 语言家族 | 自Flash 5起仿照JavaScript和ECMA-262标准设计；AS3符合ECMA-262第三版，并包含ECMAScript第四版草案工作的特性<sup>[3](http://ebook.pldworld.com/_ebook/_OReilly_/133.Books/Web_Design/action/foreword.htm)</sup><sup> • </sup><sup>[2](https://help.adobe.com/en_US/as3/components/flash_as3_components_help.pdf)</sup><sup> • </sup><sup>[4](https://jmendeth.com/snapshot/aa45ee3f904d62505f09ef2969d1885e8844859f/media/2014-05-17-reverse-engineering-flash/avm2overview.pdf)</sup> |
| 版本 | ActionScript 1（Flash 5时代）、ActionScript 2（类作为编译期语法糖）、ActionScript 3（2006年，Flash Player 9和Flex 2）<sup>[3](http://ebook.pldworld.com/_ebook/_OReilly_/133.Books/Web_Design/action/foreword.htm)</sup><sup> • </sup><sup>[5](https://www.infoworld.com/article/2178094/actionscript-for-java-developers-part-1.html)</sup> |
| 虚拟机 | AVM1运行AS1/AS2；AVM2随Flash Player 9（2006年6月）引入，以新的字节码指令集和可选的JIT编译器运行AS3<sup>[1](https://help.adobe.com/en_US/as3/learn/as3_learning.pdf)</sup><sup> • </sup><sup>[6](https://ruffle.rs/compatibility)</sup><sup> • </sup><sup>[4](https://jmendeth.com/snapshot/aa45ee3f904d62505f09ef2969d1885e8844859f/media/2014-05-17-reverse-engineering-flash/avm2overview.pdf)</sup> |
| 类型系统 | AS3支持可选的静态类型标注，类型信息在运行时保留，用于运行时类型检查<sup>[1](https://help.adobe.com/en_US/as3/learn/as3_learning.pdf)</sup> |
| 覆盖峰值 | Adobe声称Flash Player安装在近98%的联网台式机上（2005年），超过200万创意专业人士使用Flash Player 8<sup>[7](https://www.wired.com/story/history-of-macromedia-flash/)</sup><sup> • </sup><sup>[8](https://www.techtarget.com/whatis/definition/Flash)</sup> |
| 插件终结 | 到2020年7月，Flash Player浏览器插件已实际消亡，但创作工具仍在使用<sup>[9](https://arstechnica.com/information-technology/2020/07/the-rise-and-fall-of-adobe-flash/)</sup> |
| 后续生命 | Ruffle，一个基于Rust的Flash Player模拟器，支持ActionScript 1、2和3；截至2024年9月，其AS3语言支持度达到90%<sup>[10](https://github.com/ruffle-rs/ruffle/)</sup><sup> • </sup><sup>[11](https://ruffle.rs/blog/2024/09/12/optimisations-text-more)</sup> |

## 历史与版本演变

ActionScript最初只是[Flash动画](https://www.edgepedia.org/zh/flash-animation)的简单脚本机制，但到了Flash 5，其设计者选择紧密仿照JavaScript和ECMAScript标准（ECMA-262）来塑造这门语言，加入了函数、对象、控制流和数据类型。为保持播放器体积小巧，未纳入eval()的运行时求值功能，Flash 5以子集方式支持Flash 4 ActionScript。<sup>[3](http://ebook.pldworld.com/_ebook/_OReilly_/133.Books/Web_Design/action/foreword.htm)</sup>

**ActionScript 2**增加了类型标注、类和接口，但这些仅作为编译期移除的语法糖存在，以兼容较旧的ActionScript 1解释器；运行时模型并未改变。<sup>[5](https://www.infoworld.com/article/2178094/actionscript-for-java-developers-part-1.html)</sup>

**ActionScript 3**于2006年随Flash Player 9和Flex 2问世，代表核心语言的重大变革，引入了类Java的类、包、类型，以及支持可选运行时编译的新虚拟机。<sup>[5](https://www.infoworld.com/article/2178094/actionscript-for-java-developers-part-1.html)</sup> [Macromedia](https://www.edgepedia.org/zh/macromedia)将AS3语言规范提交给ECMA International，作为ECMA-262第四版的最初提案，设计上与该版本向前兼容。<sup>[12](https://archives.ecma-international.org/2005/misc/as3lang.pdf)</sup> 2006年11月，Adobe将Project Tamarin——约135,000行代码、能够运行最新JavaScript特性——捐赠给Mozilla项目。Ecma于2008年8月放弃ECMAScript 4，开始规划更精简的第五版，于2009年发布；Mozilla同年停止使用Tamarin，Tamarin于2009年终止。<sup>[13](https://thehistoryoftheweb.com/the-gift-of-code/)</sup> 2019年JSFoo的一场演讲将ActionScript 3.0描述为高度基于ES4提案，且一度是ES4的唯一可用实现，ES4的特性后来在ES6中重现。<sup>[14](https://hasgeek.com/jsfoo/2019/sub/es4-and-actionscript-a-forgotten-story-FW4NxPfUfPdVHRG4a3ULmF)</sup>

## 语言设计与执行模型

ActionScript 3.0在运行时保留类型信息，并将其用于运行时类型检查，提升了系统的类型安全性。它还包含E4X XML API（ECMA-357第二版）和基于DOM Level 3 Events的事件模型。<sup>[1](https://help.adobe.com/en_US/as3/learn/as3_learning.pdf)</sup> AS3规范将可选静态类型标注的理由阐述为：让开发者通过选择语言中定义良好的子集，以灵活性和兼容性换取可靠性和效率。<sup>[12](https://archives.ecma-international.org/2005/misc/as3lang.pdf)</sup>

Flash Player 9和10包含两个虚拟机：AVM1执行ActionScript 1.0和2.0代码，为向后兼容而保留；AVM2执行AS3。<sup>[1](https://help.adobe.com/en_US/as3/learn/as3_learning.pdf)</sup> AVM1运行Flash Player 9（2006年6月）之前制作的所有Flash内容，直到Flash Professional CC（2013年）仍可供创作者使用。<sup>[6](https://ruffle.rs/compatibility)</sup> 要使用更快的AVM2，开发者必须编写AS3。<sup>[15](https://www.digital-web.com/articles/the_road_to_actionscript_3/)</sup>

**AVM2内部机制。** AVM2由Adobe设计，用于执行ActionScript 3.0，后者符合ECMA-262第三版，并包含基于ECMAScript第四版草案工作的功能。编译后的代码以ABC文件形式传输，其内容在加载时经过验证；验证器拒绝任何不符合AVM2概览的文件。实现中可包含可选的即时编译器，将AVM2指令转换为处理器特定指令；JIT并非实现的必要条件，但能带来性能收益。<sup>[4](https://jmendeth.com/snapshot/aa45ee3f904d62505f09ef2969d1885e8844859f/media/2014-05-17-reverse-engineering-flash/avm2overview.pdf)</sup> 规范定义了二进制字节码格式，使客户端无需进行语言解析。<sup>[16](https://llvm.org/pubs/2008-09-Lightspark.pdf)</sup> Adobe的JIT编译器加上解释器、垃圾回收器和基础支持库，在x86平台上占用约1.5M未压缩字节（600k压缩后），LLVM开发者会议的一次演讲称这一体积使“带类和类型的JavaScript”成为可能。<sup>[17](https://llvm.org/devmtg/2009-10/Petersen_OptimizingActionScriptBytecode.pdf)</sup>

## ActionScript 3为何更快

Adobe的文档将性能提升归因于AVM2的新字节码指令集，并指出ActionScript 3.0代码的执行速度可达旧版ActionScript代码的十倍。<sup>[1](https://help.adobe.com/en_US/as3/learn/as3_learning.pdf)</sup> 同期的一份记述给出了Adobe自身更细致的估计：相比前代平均通用速度提升百分之八到十五，改进基于特性，因此某些特性和计算的运行速度是原来的两倍，而另一些则最高可达原来的一百倍。<sup>[15](https://www.digital-web.com/articles/the_road_to_actionscript_3/)</sup>

语言设计本身使快速执行并非易事。在ECMAScript和ActionScript模型中，即使整数和数值等基元类型也是完整的通用对象，而add等多态指令依赖运行时的参数类型，这使JIT编译变得复杂。<sup>[16](https://llvm.org/pubs/2008-09-Lightspark.pdf)</sup> 一项经同行评审的评估针对ActionScript——一种生产质量的可选类型语言——上的两个JIT编译器，测量了全类型化、部分类型化和无类型代码的性能，发现底层优化很少能使程序加速到足以收回其在可选类型语言中的投入。<sup>[18](https://dlnext.acm.org/doi/10.1145/2168696.2047853)</sup>

## 平台与工具

ActionScript 3.0的编译器内置于Adobe Flash Professional、Flash Builder和Adobe Flex SDK中。<sup>[1](https://help.adobe.com/en_US/as3/learn/as3_learning.pdf)</sup> Flex框架本身以ActionScript类实现，编译为字节码在Flash虚拟机中运行，完整框架源码随Flex SDK一同发布。<sup>[19](https://www.artima.com/articles/actionscript-3-the-language-of-flex)</sup> Flash终结后，[Adobe Animate](https://www.edgepedia.org/zh/adobe-animate)——更名后的Flash Professional——仍能打开原始.fla文件，并可借助CreateJS重新发布，以HTML5 Canvas为目标运行时。其自动AS3到[JavaScript](https://www.edgepedia.org/zh/javascript)转换仅适用于stop()和gotoAndPlay()等简单的帧脚本；真实代码库需要手动重写，而依赖Flash Player二进制本身的构造，如Stage3D和原生套接字连接，则无法移植。<sup>[20](https://www.rorschachinteractive.com/post/how-i-m-using-claude-adobe-animate-to-convert-flash-to-html5)</sup>

## 数字一览

平台巅峰时期的规模主要来自Adobe自身的声明。2005年，Adobe称Flash Player安装在近98%的联网台式机上，约70%的财富100强公司在其网站上载有Flash内容。<sup>[7](https://www.wired.com/story/history-of-macromedia-flash/)</sup> Adobe还声称超过200万创意专业人士使用了2005年发布的Flash Player 8，并估计网络上共有5.6亿用户使用Flash应用和Flash Player。<sup>[8](https://www.techtarget.com/whatis/definition/Flash)</sup> 据报道，Flash软件可在6500万台移动设备以及消费电子、电视、机顶盒和其他设备上使用，Adobe于2005年早些时候以30亿美元收购了Macromedia。<sup>[7](https://www.wired.com/story/history-of-macromedia-flash/)</sup> Flash Player 9的浏览器渗透速度异常之快，因为MySpace和YouTube等主要网站要求用户升级，Express Install也起了助推作用。<sup>[15](https://www.digital-web.com/articles/the_road_to_actionscript_3/)</sup>

## 与JavaScript、Haxe和TypeScript的比较

Adobe的詹姆斯·沃德（James Ward）将ActionScript 3描述为Adobe对ECMAScript 262第四修订版提案标准的实现，JavaScript 2.0也将基于同一标准；除了可选的静态类型标注外，与浏览器JavaScript的主要区别在于各语言所针对的DOM。<sup>[19](https://www.artima.com/articles/actionscript-3-the-language-of-flex)</sup>

与后继语言的比较关键在于类型和运行时保证。Apache Royale的文档指出，TypeScript的类型标注在编译期而非运行时强制执行，而Royale的ActionScript哲学认为，运行时类型安全通过提供某些运行时保证，使某一类JavaScript缺陷消失；Royale提供完整的开发环境，包括语言、调试工具和UI框架。<sup>[21](https://apache.github.io/royale-docs/features/as3/actionscript-vs-typescript)</sup> Haxe源自一个ActionScript 2.0编译器，这解释了两门语言之间的诸多相似之处；Haxe是严格类型化的，受ActionScript启发，支持编译器类型推断，而ActionScript强制的静态变量类型标注则不具备这一功能。<sup>[22](https://books.openfl.org/as3-conversion-guide/comparing-haxe-and-actionscript/)</sup>

## 衰落与终结

到2020年7月，Flash Player浏览器插件已实际消亡，而Flash创作工具仍然存活，在动画师和特定商业场景中仍被使用。<sup>[9](https://arstechnica.com/information-technology/2020/07/the-rise-and-fall-of-adobe-flash/)</sup> Flash曾支撑了动画、游戏、Web开发、在线广告以及桌面和嵌入式软件领域的职业和公司；在其衰落后，游戏制作者转向Unity、Game Maker、[Godot](https://www.edgepedia.org/zh/godot-game-engine)、Construct和Phaser等工具，其中许多共享了Flash以内容为中心的开发方式。<sup>[9](https://arstechnica.com/information-technology/2020/07/the-rise-and-fall-of-adobe-flash/)</sup> 在语言方面，Adobe Research发布了不完整的ActionScript 4语言参考、虚拟机规范和白皮书材料，并表示Adobe没有恢复ActionScript 4开发的计划。<sup>[23](https://github.com/adobe-research/ActionScript4)</sup>

## 近期发展

**Ruffle**是一个用[Rust](https://www.edgepedia.org/zh/rust-programming-language)编程语言编写的Adobe Flash Player模拟器，支持ActionScript 1、2和3，但其维护者称它远未完成。<sup>[10](https://github.com/ruffle-rs/ruffle/)</sup> 其2024年9月版本将ActionScript 3语言支持度从75%提升至90%，AS3 API从68%提升至76%，而AS1/2语言支持度保持在95%，团队相当确信其功能已完备。<sup>[11](https://ruffle.rs/blog/2024/09/12/optimisations-text-more)</sup> 贡献者为AVM2实现了验证器，使Ruffle能够安全地对代码做出假设并据此优化；这解锁了一个优化器通道，大幅加速了ActionScript 3内容，但仍未达到Flash Player的JIT速度。<sup>[11](https://ruffle.rs/blog/2024/09/12/optimisations-text-more)</sup> 该版本合并了来自53位贡献者的933个拉取请求，Ruffle被[Wayback Machine](https://www.edgepedia.org/zh/wayback-machine)等大型网站使用，并有正式采用的Android应用。<sup>[11](https://ruffle.rs/blog/2024/09/12/optimisations-text-more)</sup> Ruffle报告称，大多数AVM1内容可以运行，但存在一些图形不准确；大多数AVM2游戏可以正常游玩。<sup>[6](https://ruffle.rs/compatibility)</sup> Flash内容还通过[Newgrounds](https://www.edgepedia.org/zh/newgrounds)等网站上的开源浏览器内模拟得以存续。<sup>[9](https://arstechnica.com/information-technology/2020/07/the-rise-and-fall-of-adobe-flash/)</sup>

## References

1. [Learning ActionScript 3.0 (Adobe)](https://help.adobe.com/en_US/as3/learn/as3_learning.pdf)
2. [Using ActionScript 3.0 Components (Adobe)](https://help.adobe.com/en_US/as3/components/flash_as3_components_help.pdf)
3. [Foreword, ActionScript: The Definitive Guide, by Gary Grossman](http://ebook.pldworld.com/_ebook/_OReilly_/133.Books/Web_Design/action/foreword.htm)
4. [ActionScript Virtual Machine 2 Overview (Adobe)](https://jmendeth.com/snapshot/aa45ee3f904d62505f09ef2969d1885e8844859f/media/2014-05-17-reverse-engineering-flash/avm2overview.pdf)
5. [ActionScript for Java developers, Part 1 (InfoWorld)](https://www.infoworld.com/article/2178094/actionscript-for-java-developers-part-1.html)
6. [Ruffle: Compatibility](https://ruffle.rs/compatibility)
7. [The rise and fall of Flash (WIRED)](https://www.wired.com/story/history-of-macromedia-flash/)
8. [What is Adobe Flash? (TechTarget)](https://www.techtarget.com/whatis/definition/Flash)
9. [The rise and fall of Adobe Flash (Ars Technica)](https://arstechnica.com/information-technology/2020/07/the-rise-and-fall-of-adobe-flash/)
10. [ruffle-rs/ruffle (GitHub)](https://github.com/ruffle-rs/ruffle/)
11. [Optimisations, Text Input, Tab Focusing and More! (Ruffle, September 2024)](https://ruffle.rs/blog/2024/09/12/optimisations-text-more)
12. [ActionScript 3 Language Specification (ECMA International archive)](https://archives.ecma-international.org/2005/misc/as3lang.pdf)
13. [The Gift of Code (The History of the Web)](https://thehistoryoftheweb.com/the-gift-of-code/)
14. [ES4 and ActionScript: A Forgotten Story (JSFoo 2019)](https://hasgeek.com/jsfoo/2019/sub/es4-and-actionscript-a-forgotten-story-FW4NxPfUfPdVHRG4a3ULmF)
15. [The Road to ActionScript 3 (Digital Web)](https://www.digital-web.com/articles/the_road_to_actionscript_3/)
16. [An efficient ActionScript 3.0 Just-In-Time compiler implementation (LLVM)](https://llvm.org/pubs/2008-09-Lightspark.pdf)
17. [Optimizing ActionScript Bytecode using LLVM (LLVM Developers' Meeting)](https://llvm.org/devmtg/2009-10/Petersen_OptimizingActionScriptBytecode.pdf)
18. [The impact of optional type information on JIT compilation of dynamically typed languages (ACM SIGPLAN Notices)](https://dlnext.acm.org/doi/10.1145/2168696.2047853)
19. [ActionScript 3: The Language of Flex (Artima interview)](https://www.artima.com/articles/actionscript-3-the-language-of-flex)
20. [How I'm Using Claude + Adobe Animate to Convert Flash to HTML5](https://www.rorschachinteractive.com/post/how-i-m-using-claude-adobe-animate-to-convert-flash-to-html5)
21. [ActionScript vs TypeScript (Apache Royale documentation)](https://apache.github.io/royale-docs/features/as3/actionscript-vs-typescript)
22. [Comparing Haxe and ActionScript (OpenFL conversion guide)](https://books.openfl.org/as3-conversion-guide/comparing-haxe-and-actionscript/)
23. [adobe-research/ActionScript4 (GitHub)](https://github.com/adobe-research/ActionScript4)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Programming languages › Individual programming languages › C-family and imperative languages

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/actionscript

English original: https://www.edgepedia.org/actionscript
