ActionScript 2 中缺少的 Flash ActionScript 3 功能 [英] Flash ActionScript 3 capabilities lacking in ActionScript 2

查看:37
本文介绍了ActionScript 2 中缺少的 Flash ActionScript 3 功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从 Adob​​e 推出带有 Flash Player 9 的 ActionScript 3 以来,我们中的许多人一直在缓慢地切换.简而言之,我想知道作为框架的 AS3 可以做什么,这在 AS2 中根本不可能或非常困难.我不是在谈论现成的组件,而是内置的类,例如用于 Web 远程处理、二进制数据操作、XML 处理等.

Ever since Adobe introduced ActionScript 3 with Flash Player 9, many of us have been slow to switch over. In short I'd like to know what AS3 as a framework can do, that is simply impossible or significantly difficult in AS2. I'm not talking about readymade components, but built-in classes such as for web remoting, binary data manipulation, XML handling, etc.

推荐答案

嗯,实际上,AS3 是一种语言,而不是框架……flash player API 具有类似框架的特征……但是好吧,我们不要争论术语...那么 Flash Player 9 有什么很酷的东西(除了已经提到的东西)?

well, actually, AS3 is a language, not a framework ... the flash player API has framework like traits ... but ok, let's not argue about terminology ... so what's cool in flash player 9 (other than things that were mentioned already)?

  • 一些让你的生活更轻松的语言特性:方法闭包(不需要 Delegate)、可选参数(与 AS2 可选参数相比节省了很多时间,这是一种 hack),实例范围解析(您可以从在该实例的方法中声明的匿名函数中访问实例的成员,因此不需要 var self = this;)
  • 通用 API 设计:API 更简洁,封装合理,常量定义正确(在许多类中,如 flash.filters.BitmapFilterType),并且公开了很多内容更多的东西,并提供适当的错误处理
  • package flash.net:
    • Socket:真正的套接字,而不是 XML 套接字……这允许实现任何基于 TCP 的协议
    • URLStream:这其实很强大,但我个人总是使用套接字来代替
    • a couple of language features making your life A LOT easier : method closures (no need for Delegate), optional arguments (saves a lot of time compared to AS2 optional arguments, which are rather a hack), instance scope resolution (you can access members of an instance from within an anonymous function declared in a method of that instances, so no need for var self = this;)
    • general API design : API is much cleaner, sensibly packaged, has constants properly defined (in many classes like flash.filters.BitmapFilterType), and exposes quite a lot more things, and offers proper error handling
    • package flash.net:
      • Socket: real sockets, instead of XML sockets ... this allows any TCP based protocol to be implemented
      • URLStream: this is actually quite powerfull, but personally, i always use sockets instead
      • Loader::loadBytes:允许在运行时使用 ActionScript 生成 swf 并直接加载到播放器中,以及手动缓存
      • Stage::frameRate:最后,你可以在运行时改变它
      • DisplayObject::getBounds &DisplayObject::getRect:比摆弄 AS2 等效项的这个极其愚蠢的返回值要好得多...
      • Loader::loadBytes: allows to generate swf at runtime with ActionScript and load them into the player directly, as well as manual caching
      • Stage::frameRate: finally, you can change it at runtime
      • DisplayObject::getBounds & DisplayObject::getRect: much better, than fiddling around with this incredibly stupid return value of the AS2 equivalent ...
      • ByteArray:在合理的时间内处理二进制数据...这允许 JPG 或 PNG 压缩,在客户端创建 PDF 等等
      • Dictionary:允许将对象映射到对象...这非常方便(您可以将其破解到 AS2 中,但这不是您的问题,对吧?)...例如,这对于创建集合或将对象映射到处理程序等非常有用.
      • Proxy:代理类非常强大,玩起来非常有趣,真的......将它用于代理、集合、AOP 等......
      • Timer:好的,现在这可以很容易地在 AS2 中重新实现,但除此之外,我认为它比摆弄 setInterval 要干净得多 ...
      • ByteArray: manipulation of binary data in reasonable time ... this allows JPG or PNG compression, PDF creation on client side, and so on
      • Dictionary: allows mapping objects to objects ... this can come in very handy (you could hack that into AS2, but that wasn't your question, right?) ... for example, this is great for creating sets, or mapping objects to handlers, etc.
      • Proxy: the proxy class is so damn powerful and so much fun to play with, really ... use it for proxies, collections, AOP, etc. ...
      • Timer: ok, now this can quite easily be reimplemented in AS2, but apart from that, i think it's much cleaner than fiddling arount with setInterval ...
      • TextField:更大的 API,允许许多很酷的东西,例如获取字符/行指标等...
      • Font.registerFont:允许在运行时嵌入字体
      • 整体设计更加简洁和强大
      • TextField: much bigger API, allows many cool things, as getting character/line metrics, etc. ...
      • Font.registerFont: allows embedding fonts at runtime
      • overall design is much cleaner and powerful

      请注意,事件模型和显示列表可以在 AS2 中重新实现,但需要额外的性能成本,但我认为这是关于内置功能...

      note that event model and diplay list can be reimplemented in AS2 at additional performance cost, but i think it was about built-in features ...

      我想,就是这样......

      i think, that's about it ...

      问候

      back2dos

      这篇关于ActionScript 2 中缺少的 Flash ActionScript 3 功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆