将现有项目从 Flash 7/AS2 迁移到 Flex/AS3 的最佳方法是什么? [英] What is the best approach to moving a preexisting project from Flash 7/AS2 to Flex/AS3?

查看:19
本文介绍了将现有项目从 Flash 7/AS2 迁移到 Flex/AS3 的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个针对 Flash 7 的大型代码库,其中包含 很多 AS2 类.我希望我能够将 Flex 用于任何新项目,但我们路线图中的许多新内容是对旧代码的补充.

I have a large codebase that targetted Flash 7, with a lot of AS2 classes. I'm hoping that I'll be able to use Flex for any new projects, but a lot of new stuff in our roadmap is additions to the old code.

AS2 和 AS3 的语法通常是相同的,所以我开始怀疑将当前代码库移植到 Flex/AS3 会有多困难.我知道所有与 UI 相关的东西都是不确定的(目前 UI 是在运行时生成的,有很多 createEmptyMovieClip() 和 attachMovie() 东西),但 UI 和控制器/模型的东西大多是分开的.

The syntax for AS2 and AS3 is generally the same, so I'm starting to wonder how hard it would be to port the current codebase to Flex/AS3. I know all the UI-related stuff would be iffy (currently the UI is generated at runtime with a lot of createEmptyMovieClip() and attachMovie() stuff), but the UI and controller/model stuff is mostly separated.

有没有人尝试将大量的 AS2 代码库移植到 AS3?有多难?你遇到了哪些陷阱?对做这种项目的方法有什么建议吗?

Has anyone tried porting a large codebase of AS2 code to AS3? How difficult is it? What kinds of pitfalls did you run into? Any recommendations for approaches to doing this kind of project?

推荐答案

我在尝试将大量 AS2 类转换为 AS3 时发现的一些值得注意的问题:

Some notable problems I saw when attempting to convert a large number of AS2 classes to AS3:

class your.package.YourClass
{
}

变成

package your.package
{
    class YourClass
    {
    }
}

需要导入

您必须显式导入任何使用的外部类——仅用它们的完全限定名称来引用它们是不够的.

Imports are required

You must explicitly import any outside classes used -- referring to them by their fully qualified name is no longer enough.

这完全有道理,但 AS2 会让您这样做,因此如果您有任何需要删除的内容.

This makes total sense, but AS2 will let you do it so if you have any they'll need to be removed.

任何覆盖父类函数的函数都必须使用 override 关键字声明,很像 C#.同样,如果您有扩展其他接口和重新声明函数的接口,则必须删除这些覆盖(同样,与 public 一样,这种表示法无论如何都没有意义,但 AS2 允许您这样做).

Any functions that override a parent class function must be declared with the override keyword, much like C#. Along the same lines, if you have interfaces that extend other interfaces and redeclare functions, those overrides must be removed (again, as with public, this notation didn't make sense anyway but AS2 let you do it).

您在上面提到了这一点,但它现在是 flash.display.MovieClip 而不是例如 MovieClip.这个类别有很多细节,我没有找到所有的细节,但这里会有很多烦恼.

You alluded to this above, but it's now flash.display.MovieClip instead of just MovieClip, for example. There are a lot of specifics in this category, and I didn't get far enough to find them all, but there's going to be a lot of annoyance here.

我没有开始将这种转换工作到成功的程度,但是我能够在几个小时内编写一个快速的 C# 工具来处理除覆盖之外的所有方面关键词.自动化导入可能很棘手——在我的例子中,我们使用的所有包都从几个根级别的包开始,因此它们很容易被检测到.

I didn't get to work on this conversion to the point of success, but I was able in a matter of hours to write a quick C# tool that handled every aspect of this except the override keyword. Automating the imports can be tricky -- in my case the packages we use all start with a few root-level packages so they're easy to detect.

这篇关于将现有项目从 Flash 7/AS2 迁移到 Flex/AS3 的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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