Flex 4.5 和 4.6 之间的 Spark 生命周期变化 [英] Spark lifecycle changes between Flex 4.5 and 4.6

查看:15
本文介绍了Flex 4.5 和 4.6 之间的 Spark 生命周期变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将我的一些项目迁移到了全新的 Flex 4.6 SDK.我没想到会有很多麻烦,因为它只是一个小版本.但事实上,我到处都遇到了数百个错误.这些错误大多来自 Spark SkinnableComponents;例如:

I have recently migrated some of my projects to the shiny new Flex 4.6 SDK. I wasn't expecting much trouble since it was only a minor release. But as a matter of fact I got hundreds of errors all over the place. These errors would mostly come from Spark SkinnableComponents; for example:

override protected function getCurrentSkinState():String {
    return mySkinPart.someProperty ? "normal" : "someOtherState";
}

在 4.5 下可以正常工作,但在 4.6 中会抛出 nullpointer 错误.原因很简单:在 4.6 中 getCurrentSkinState() 在创建皮肤部件之前调用,而在 4.5 中我可以确定默认状态下的皮肤部件会存在.

would work just fine under 4.5, but would throw me a nullpointer error in 4.6. The reason is simple enough: in 4.6 getCurrentSkinState() is called before the skinparts are created, whereas in 4.5 I could be certain that the skinparts in the default state would be there.

进一步调查使我相信皮肤的初始状态现在是 undefined 而不是 States 数组中的第一个状态(直到它调用 getCurrentSkinState() 即).

Further investigation led me to believe that the initial state of a Skin is now undefined instead of the first state in the States array (until it calls getCurrentSkinState() that is).

解决这些问题通常很容易,我只需要更多的防御性编程.但这不是我真正的问题.

Fixing these problems is usually pretty easy and requires just somewhat more defensive programming from my part. But that's not my real issue.

真正的问题是,如果组件生命周期发生了变化,我想确切地知道什么发生了变化以及我的项目的哪些部分可能会受到影响.

The real issue is that if the component lifecycle has changed, I'd like to know exactly what has changed and what parts of my projects might be affected.

如果有人能对此有所了解或至少指出我可以阅读所有相关信息的正确位置,我将非常感激(因为我能找到的唯一发行说明仅涵盖新的移动组件).

I would be very appreciative if someone could shed some light on this or at least point me to the right place where I can read all about it (because the only release notes I could find were only covering the new mobile components).

编辑(这不会改变问题;我只是想与您分享我的发现)

Edit (this doesn't change the question; I just wanted to share my findings with you)

我刚刚遇到的另一个问题:dynamic 修饰符似乎不再被子类继承.这是一个纯粹的 ActionScript 问题,所以我猜是编译器对它的处理方式不同.

Another issue I just ran into: the dynamic modifier seems to no longer be inherited by subclasses. This is a pure ActionScript issue, so I guess it's the compiler that treats it differently.

让我解释一下.考虑这个类:

Let me explain. Consider this class:

public class MyClass extends Array { }

现在,如果我尝试像这样将新项目推送到这个自定义数组中:

Now, if I try to push a new item into this custom Array like this:

var t:Array = new MyClass();
t.push("hello");

  • SDK 4.5.1:没问题
  • SDK 4.6:运行时无法在 MyClass 上创建属性 0"
  • 显然这是因为 Array 是动态的,而 MyClass 不是,所以很容易修复:

    Apparently that's because Array is dynamic and MyClass isn't, so it's easily fixed:

    public dynamic class MyClass extends Array { }
    

    并且错误消失了.

    但是,如果我使用的第三方库包含这样的代码并且我没有源代码访问权限怎么办?我的应用程序会中断,我无法修复它.我的意思是:来吧,对于一个 dot-release 来说,这可不是什么小改动.

    But what if I used a third-party library that has code like this and to which I had no source code access? My application would break and there's no way I could fix it. I mean: come on, that's no minor change for a dot-release.

    推荐答案

    我觉得里面有两个问题.

    I think there are two questions in there.

    1) 真正的问题是,如果组件生命周期发生了变化,我会想确切地知道发生了什么变化以及我的项目的哪些部分可能会受到影响.

    1 ) The real issue is that if the component lifecycle has changed, I'd like to know exactly what has changed and what parts of my projects might be affected.

    我还没有看到对两个版本之间差异的全面低级分析.如果你真的很担心,并且你有空闲的时间,你可以使用一个 diff 工具来比较两个 SDK 的源代码.不应该有太多重大的结构变化 - 例如.重命名的类或包,所以它可能不是那么糟糕.我预计很多课程根本不会改变.

    I haven't seen a comprehensive low-level analysis of the differences between the two version. If you are really concerned, and you have the time to spare, you could use a diff tool to compare the source code for the two SDK's. There shouldn't be too many major structural changes - e.g. renamed classes or packages, so it might not be so bad. I expect a lot of classes won't have changed at all.

    2 ) 我刚刚遇到的另一个问题:动态修饰符似乎不再被子类继承.这是一个纯粹的 ActionScript 问题,所以我猜猜是编译器对待它的方式不同.

    2 ) Another issue I just ran into: the dynamic modifier seems to no longer be inherited by subclasses. This is a pure ActionScript issue, so I guess it's the compiler that treats it differently.

    这个比较容易.dynamic 从未被继承.Object 是动态的,所以如果属性被继承,每个类也必须是动态的.

    This one is easier. dynamic has never been inherited. Object is dynamic, so if the attribute was inherited every class would have to be dynamic too.

    如果与动态类实例相关的行为似乎发生了变化,那么您的代码中还有其他事情发生.

    If there appears to be a change in behaviour related to dynamic class instances, then there is something else going on in your code.

    这篇关于Flex 4.5 和 4.6 之间的 Spark 生命周期变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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