什么是移动preexisting项目从Flash 7 / AS2来的Flex / AS3的最佳方法?方法、项目、Flash、preexisting

2023-09-08 13:42:27 作者:低頭親親妳

我有AS2类的大codeBase的是针对性的Flash 7,用的很多的。我希望,我就可以使用Flex任何新的项目,但很多新的东西,在我们的路线图是增加的老code。

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是大致相同的,所以我开始怀疑,这将是多么难是端目前的codeBase的弯曲/ AS3。我知道所有的UI相关的东西会是前途未卜(目前的用户界面在运行时产生了大量createEmptyMovieClip()和attachMovie()创建的东西),但用户界面和控制器/模型的东西大多是分离的。

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 code大codeBase类到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.

这是重载父类功能的任何功能,必须使用的覆盖的关键字来声明,很像C#。按照同样的思路,如果你有其他的扩展接口和重新定义函数的接口,这些替代必须拆除(再次,与公开,的这个符号没有任何意义,但无论如何,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.