问题描述
我目前的开发栈是 MySQL + iBatis + Spring + Spring BlazeDS Integration 1.01 + BlazeDS 3.2 和 Flex 3 with Mate 0.8.9 框架.现在 Flash Builder 4 beta 2 出来了.有一些很酷的功能,如数据中心开发 (DCD)、表单生成等......你知道 Spring Blazeds 集成如何与 BlazeDS 4 一起工作吗?马特呢?Flex 4 有什么问题吗?DCD 如何与 mate eventmaps 配合使用.我知道最好自己尝试一下,但我只想检查是否有人尝试过迁移 Flex 4.如果是这样,有什么问题?您是否注意到任何生产力加速?谢谢.
My current development stack is MySQL + iBatis + Spring + Spring BlazeDS Integration 1.01 + BlazeDS 3.2 and Flex 3 with Mate 0.8.9 framework. Now Flash Builder 4 beta 2 is out. There are cool features like Data Centric Development (DCD), form generation etc... Do you know how Spring Blazeds Integration works with BlazeDS 4? What about Mate? Is there any issues with Flex 4 ? How DCD suits with mate eventmaps. I know it is better to try it out myself but I just want to check if somebody ever tried to migrate Flex 4. If so what are the issues? Did you notice any productivity speed up? Thanks.
推荐答案
我无法告诉您有关迁移第三方组件的任何信息.我不使用你提到的那些.
I can't tell you anything about migrating your third-party components. I don't use the ones you've mentioned.
但是,我可以告诉您,您无法简单地将现有项目加载到 Flash Builder 4 中,将 SDK 更改为 4.0,并期望它重新编译.Flex 4 中发生了大量变化,通常不兼容.
I can tell you, however, that you won't be able to simply load your existing project up into Flash Builder 4, change the SDK to 4.0, and expect it to recompile. A huge number of things have changed in Flex 4, often incompatibly.
以下是我目前遇到的:
您现在拥有两个并行组件库,Spark 和 MX.MX 是旧的 Flex 3 组件库,有时称为 Halo,尽管从技术上讲这只是默认皮肤的名称.Spark 是新的 Flex 4 组件库,仅部分替代了 MX.
You now have two parallel component libraries, Spark and MX. MX is the old Flex 3 component library, sometimes called Halo, though that's technically just the name of the default skin. Spark is the new Flex 4 component library, which only partially replaces MX.
它们确实可以互操作.您可以在单个应用程序中同时使用两者,并且您可以执行诸如将 Spark 组件放入 ViewStack
等 MX 布局容器中的操作.在应用程序中也有自然的划分,其中一侧使用 Spark,另一侧使用 MX,无需担心出现问题,因为它们不在 GUI 级别进行互操作.例如,对话框就是这样.
They do interoperate. You're allowed to use both in a single app, and you can do things like put Spark components in MX layout containers like ViewStack
. There are also natural divisions in an application where it's possible to have one side using Spark, the other MX, with no worry about trouble because they don't interoperate at a GUI level. Dialog boxes are like that, for instance.
他们做这一切的原因是为了支持您听说过的这种新皮肤:Flash催化剂、FXG等等.如果你使用 Halo 原版皮肤,除了它是未来这一事实之外,我认为 Spark 对你来说并不重要.
The reason they did all this is to support this new skinning stuff you've been hearing about: Flash Catalyst, FXG, and all that. If you use the stock Halo skin, I don't see that Spark matters to you, other than the fact that it's The Future.
(旁白:获得绿野仙踪回声效果的 Markdown 语法是什么?)
(Aside: What's the Markdown syntax to get the Wizard-of-Oz boomy echo effect?)
Joan Lafferty(Flex SDK 质量主管)有一篇很有价值的文章,Flex 之间的差异3 和 Flex 4.在 第 4 页 上,她有一张表格,列出了 Flex 3 MX 组件在 Flex 4 中还没有被 Spark 组件取代.其中大部分没有自己的外观,比如 Accordion
,所以你不需要给它们换皮肤,或者像对话框一样的东西,比如 .(你应该通读那篇文章的其余部分.它涵盖了我不知道的东西,因为我还没有遇到所有的差异.)
Joan Lafferty (Flex SDK Quality Lead) has a valuable article, Differences between Flex 3 and Flex 4. On page 4, she has a table listing the Flex 3 MX components that have not been replaced by Spark components in Flex 4. Most of these have no appearance of their own, like Accordion
, so you don't need to skin them, or are things like dialog boxes, like Alert
. (You should read through the rest of that article. It covers things I don't, because I haven't run into all of the differences yet.)
说到皮肤,Flex 4 中只支持 Flex 3 中的两个 MX 皮肤.色彩更丰富的 MX 皮肤已经消失,尽管有一组新的基于 Spark 的彩色皮肤炫耀一些您可以使用 FXG 等进行的操作.如果您真的喜欢他们删除的其中一个,您无疑可以在 Spark 上重新创建它们,但它不是开箱即用的.
Speaking of skins, only two of the MX skins from Flex 3 are still supported in Flex 4. The more colorful MX skins are gone, though there is a new set of colorful Spark-based skins that show off some of the things you can do with FXG and such. If you really liked one of the ones they removed, you can doubtless recreate them atop Spark, but it's not available out of the box.
许多内容已经重命名,还有一些 SparkMX 组件的替代品具有不同的接口,因此具有不同的名称.例如,要完全迁移到 Spark,您必须将 VBox
es 更改为 VGroup
s.有很多类似的令人讨厌的小差异.
Many things have been renamed, and some Spark replacements for MX components have different interfaces and so have different names. For instance, to move entirely to Spark, you'll have to change your VBox
es to VGroup
s. There are lots of annoying little differences like that.
由于整个双 GUI 库的问题,Adobe 发现自己有一堆 MXML 标签,例如 和
它实际上不是 MX 的一部分,它对 Spark 也同样适用.他们没有使用重复的标签集,而是将这些标签移至新的 XML 名称空间.对于那些对现有的基于 MX 的应用程序进行分段迁移的人来说,这是一个问题,因为这意味着您仍在使用
mx
MX 组件库的别名,所以这些对两个库都通用的标签必须重命名.这些标签的新 XML 命名空间默认为 fx
,因此每个 都必须重命名为
> 等等.IDE 在导入项目时不会为您执行此操作.您只需在尝试构建导入的项目时一一找到它们即可.
Because of the whole dual GUI library thing, Adobe found themselves with a bunch of MXML tags like <Script>
and <Style>
that aren't actually part of MX, which work just as well for Spark. Rather than have a duplicate set of tags, they moved these to a new XML namespace. This is a problem for those doing piecewise migration of existing MX-based apps, because it means you're still using the mx
alias for the MX component library, so these tags that are common to both libraries all have to be renamed. The new XML namespace default for these tags is fx
, so every <mx:Script>
has to be renamed to <fx:Script>
, and so on. The IDE doesn't do this for you on importing the project. You just find them one by one as you try to get your imported project to build.
如果您打算完全迁移到 Spark,您可以在这里避免一些痛苦.您可以让它继续使用 mx
,而不是在非 MX 标签上接受 fx
默认命名空间别名,因为 MX 和 Spark 不需要它使用 s
作为其默认值.
If you're planning to move entirely to Spark, you can avoid some pain here. Instead of accepting the fx
default namespace alias on the non-MX tags, you can let it continue to use mx
, since you won't need that for MX, and Spark uses s
as its default.
安装 Flash Builder 4 后的第一项任务应该是生成一个全新的项目,以便您可以研究它并从中复制粘贴诸如这些命名空间声明之类的内容.
Your first task after installing Flash Builder 4 should be to generate a fresh new project so you can study it and copy-paste things like these namespace declarations from it.
整个 MX 与 Spark 和命名空间混乱的另一个后果是您的 CSS 可能需要调整.为此,Flex 有一个非标准的 CSS 扩展,如下所示:
Another fallout of the whole MX vs. Spark and namespace mess is that your CSS might need tweaking. Flex has a non-standard extension to CSS for this, which looks like this:
@namespace mx "library://ns.adobe.com/flex/mx";
mx|Application {
....
Flex 3 和 Flex 4 之间的所有命名空间 URL 都已更改,并且在 Flex 4 测试版过程中至少有一次再次更改.
http://www.adobe.com/2006/mxml
现在是 http://ns.adobe.com/mxml/2009
library://ns.adobe.com/flex/halo
现在是 library://ns.adobe.com/flex/mx
用于通过 CSS 中的通用名称指定嵌入字体名称的 local()
形式不再起作用.您必须使用 url()
形式并提供字体文件的路径.
The local()
form for specifying embedded font names by their common name in CSS doesn't work any more. You have to use url()
form and give the path to the font file.
这里要注意的一个陷阱是,这意味着如果您要嵌入单个字体的多个变体(例如普通和粗体),您之前的代码引用了相同的字体名称,但您的新代码将指向两个不同的文件,因为两个权重不在同一个 .ttf 或 .otf 文件中.例如,这个:
A trap to beware of here is that this means if you're embedding multiple variants of a single font (e.g. normal and bold weights) your previous code referred to the same font name, but your new one will point to two different files because the two weights aren't in the same .ttf or .otf file. For instance, this:
@font-face {
src: local("Verdana");
fontFamily: VerdanaEmbedded;
fontWeight: normal;
}
@font-face {
src: local("Verdana");
fontFamily: VerdanaEmbedded;
fontWeight: bold;
}
必须改成这样:
@font-face {
src: url("/Library/Fonts/Verdana.ttf");
fontFamily: VerdanaEmbedded;
fontWeight: normal;
}
@font-face {
src: url("/Library/Fonts/Verdana Bold.ttf");
fontFamily: VerdanaEmbedded;
fontWeight: bold;
}
在 Flex 3 中,编译器根据 fontWeight
属性猜测上述代码指的是哪两个 .ttf 字体文件.在 Flex 4 中,编译器让您明确地告诉它.
In Flex 3, the compiler guessed which two .ttf font files the above code is referring to based on the fontWeight
attribute. In Flex 4, the compiler makes you tell it explicitly.
如果您在应用程序中嵌入字体并继续使用 MX 控件,则文本可能会消失或恢复为默认字体.这是因为,默认情况下,Flex 4 在底层使用不同的字体嵌入机制来支持 Flash Player 10 中改进的字体渲染引擎.要以旧方式嵌入字体以便旧的 MX 控件仍然可以使用它,您可以必须将 embedAsCFF
CSS 属性设置为 false
.
If you embed fonts in your application and continue to use MX controls, the text is likely to either disappear or revert to the default font. This is because, by default, Flex 4 uses a different font embedding mechanism under the hood to support the improved font rendering engine in Flash Player 10. To embed a font in the older way so that the old MX controls can still use it, you have to set the embedAsCFF
CSS attribute to false
.
状态机制完全不同.此 Flex 3 代码:
The states mechanism is entirely different. This Flex 3 code:
<mx:State name="alternate">
<mx:SetProperty target="{myField}" name="editable" value="false"/>
</mx:State>
....
<mx:Form ...>
<mx:TextInput id="myField"/>
....
</mx:Form>
在 Flex 4 中变成这样:
becomes this in Flex 4:
<mx:State name="alternate"/>
....
<mx:Form ...>
<mx:TextInput id="myField" editable.alternate="false"/>
....
</mx:Form>
新方法对我来说更有意义,因为它将所有单独的组件状态放在组件标签本身中,而不是在 MXML 文件的顶部以冗长的 <mx:State>
块,但移植到新机制有点麻烦.IDE 不会自动执行转换,尽管它确实可以自动执行.
The new way makes more sense to me, since it puts all the individual component states in the component tag itself, instead of way up at the top of the MXML file in a verbose <mx:State>
block, but porting to the new mechanism is a bit of a grind. The conversion isn't automated by the IDE, although it really could be.
有些标签不再允许作为 标签的直接子代.它们分为几类:验证器、效果等.您现在必须将它们打包到一个新的
标签中,如下所示:
There are some tags no longer allowed as direct children of the <Application>
tag. These fall into several categories: validators, effects, etc. You now have to pack these up into a new <fx:Declarations>
tag, like so:
<fx:Declarations>
<mx:Dissolve id="myTransition" duration="100" target="{this}"/>
</fx:Declarations>
Flash Builder 中有一个新的项目选项,可让您继续单独使用 Flex 3.5 SDK,完全不使用 Spark,以便更轻松地迁移.这对初始测试很有好处,但在某些时候您想要继续前进,此时您必须应对上述所有问题.
There's a new project option in Flash Builder that lets you continue using the Flex 3.5 SDK alone, with no Spark at all, for easier migration. That's good for initial tests, but at some point you want to move forward, at which point you have to contend with all the above.
新编译器对我来说似乎也没有那么快.我没有对其进行基准测试,只是继续感觉,这对我来说真正重要,因为它仍然让我觉得我的头撞在我的桌子上.:) 它当然没有在我的开发箱中使用其他 7 个内核.嗯.
The new compiler doesn't seem all that much faster to me, either. I haven't benchmarked it, just going on feel, which is what really matters to me, since it still makes me feel like pounding my head on my desk. :) It certainly isn't using the other 7 cores in my development box. Grrr.
这篇关于任何 Flex 4 迁移经验?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!