2 Replies Latest reply on Apr 1, 2010 12:11 AM by zhouweifiles

    类型转换错误

    zhouweifiles

           大家好,我在使用flex的过程中碰到了让人很头痛的一个问题。

           我使用了两个模块(module)A和B,当模块A首先加载的时候,A运行正常,接着加载B模块,则B模块中会有类型转换的错误。通过调试发现是这样的现象:var item:TOrganization=event.item as TOrganization;     其中event.item显示的数据类型为TOrganization,但是运行完这条语句后,item显示为null。     如果我先运行模块B,则var item:TOrganization=event.item as TOrganization;这条语句可以正常运行,item将会得到我所想要的值,如果再加载模块A的话,则出现同学的类型转换错误,求解,谢谢!

        • 1. Re: 类型转换错误
          Vikash.kumar29 Level 3

          Hello,

           

          As per my understanding you are using TOrganization class in both Module A and Module B, but when you loads both module the signature of class get differed and will lead to type coersion error when typecasting object of TOrganization from Module A to Module B or vice versa.

           

          You can solve your problem by a creating a library project which contain your shareable code among both modules which also include TOrganization class.

          Now use this libary .swc file in both module and set the linkage as run-time-shared library. This leads flash player to hold only a single information of all shared class and then you can safely typecast object from module A to Module B or vice- versa.

           

           

          Hope this helps you

          -Vikash

          • 2. Re: 类型转换错误
            zhouweifiles Level 1

            谢谢你的解答。

            我已经找到问题的原因了,我在两个模块中都使用了RemoteObject,而且使用的版本是sdk3.2。在网上面有不少关于RemoteObject module sdk3.2的问题,我参考了他们的信息并将问题解决了。