flex3升级到flex4.1时候遇到的一个问题。Compiler error with selectedChild in Flex 4 with code that worked in Flex 3

A customer filed a bug recently about a backwards compatibility issue that they ran into when trying to compile their Flex 3 application in Flex 4. Normally, your application should compile just fine, but, you might run into some behavioral differences between the two releases.  However, in the case described in bug SDK-25021, your application won’t even compile! When using the ‘selectedChild’ property for any of the MX Navigators like TabNavigator, ViewStack or Accordion, you will get the following error in Flex 4:

Error: Implicit coercion of a value of type mx.core:INavigatorContent to an unrelated type flash.display:DisplayObject.

myViewStack.removeChild(myViewStack.selectedChild)

This code compiled fine in Flex 3, but, won’t compile in Flex 4. Unfortunately, we had to loosen the type of the selectedChild property to get the MX navigators working with Flex 4 Spark content. The type of selectedChild was ‘Container’, now it is ‘INavigatorContent’. In Flex 4, both the Container and NavigatorContent classes implement INavigatorContent. You will need to make some minor tweaks to your Flex 3 code to have it compiling in Flex 4.

To resolve the compile error, just cast your selectedChild property to a Container. For example, here is the Flex 3 code converted to Flex 4 code:

Flex 3: myViewStack.removeChild(myViewStack.selectedChild)

Flex 4: myViewStack.removeChild(Container(myViewStack.selectedChild))
I hope this makes the migration easier. Good luck!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值