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

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

问题描述

我最近将一些项目迁移到了新的Flex 4.6 SDK。因为这只是一个小小的发行版本,所以我不期待太多麻烦。但事实上,我到处都有数百个错误。这些错误主要来自Spark SkinnableComponent s;例如:

pre $重写protected function getCurrentSkinState 正常:someOtherState;

$ / code $ / pre

可以在4.5以下工作,但是会给我一个 nullpointer 4.6中的错误。原因很简单:在创建皮肤部件之前调用4.6 getCurrentSkinState(),而在4.5中,我可以确定处于默认状态的皮肤部件将在那里。

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

解决这些问题通常很简单,只需要更多的防御性编程。但这不是我真正的问题。真正的问题是如果组件生命周期发生了变化,我想知道确切的 >什么已经改变,我的项目的哪些部分可能会受到影响。

如果有人可以点亮这个或至少一点,我将非常感激我到了可以阅读所有内容的正确位置(因为我能找到的唯一的发行说明只包括新的移动组件)。




编辑(这不会改变问题;我只是想和你分享我的发现)另一个问题我刚刚遇到:动态修饰符似乎不再被子类继承。这是一个纯粹的ActionScript问题,所以我想这是编译器对待它的不同。



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

  public class MyClass extends Array {} 

$ b现在,如果我试图将一个新项目推入这个自定义数组,如下所示:

$ pre code> var t:Array = new MyClass();
t.push(hello);




  • SDK 4.5.1:没问题
  • SDK 4.6:在MyClass上不能创建属性0


显然这是因为Array是动态的,MyClass isn' t,所以很容易修复:

  public dynamic class MyClass extends Array {} 

,错误消失了。但是,如果我使用了一个这样的代码而且没有源代码访问的第三方库呢?我的应用程序会中断,我无法修复它。我的意思是:来吧,这是一个点释放没有小的变化。

解决方案

我认为有两个问题在那里。

lockquote
1)真正的问题是,如果组件生命周期发生了变化,我会
喜欢知道到底发生了什么变化和我的项目
的哪些部分可能会受到影响。

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


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

这个更容易。 动态从未被继承过。 Object 是动态的,所以如果这个属性被继承了,那么每个类都必须是动态的。



要改变与动态类实例有关的行为,那么代码中还有其他的东西。


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";
}

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.

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)

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: no problem
  • SDK 4.6: "Cannot create property 0 on MyClass" at runtime

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

public dynamic class MyClass extends Array { }

and the error's gone.

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 ) 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 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 ) 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.

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.

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

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