Flex ArgumentError: Error #2173: Unable to read object in stream

Categories: Flex; Tagged with: ; @ April 23rd, 2011 23:04

Class写的没有问题, 实现了IExternalizable 接口, 但总是报错:

ArgumentError: Error #2173: Unable to read object in stream.  The class com.liguoliang.helloworld.Department does not implement flash.utils.IExternalizable but is aliased to an externalizable class.
    at ObjectInput/readObject()
    at mx.collections::ArrayList/readExternal()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\collections\ArrayList.as:586]
    at mx.collections::ArrayCollection/readExternal()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\collections\ArrayCollection.as:147]
    at ObjectInput/readObject()
    at mx.messaging.messages::AbstractMessage/readExternal()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\messaging\messages\AbstractMessage.as:486]
    at mx.messaging.messages::AsyncMessage/readExternal()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\messaging\messages\AsyncMessage.as:170]
    at mx.messaging.messages::AcknowledgeMessage/readExternal()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\messaging\messages\AcknowledgeMessage.as:95]

找来找去找不到原因, 后来发现在App中根本没有使用过这个类!  很久没开发Flex, 把这么个事给忘了… 个人感觉应该报Class not found的错啊 🙁

对于没有使用过的类, 可以在App中引用一下, 确保在编译时不要被忽略:

 

			// 本例中未试过用Department类, 仅作引用;
			private static function __ref():void {
				Department;
			}

<->



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.