我需要在Flex中扩展一个ArrayCollection来实现this之类的东西。但是当我将它发送到服务器时,似乎序列化失败了。
ArgumentError: Error #2004: One of the parameters is invalid.
at ObjectOutput/writeObject()
at mx.collections::ArrayList/writeExternal()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ArrayList.as:595]
at mx.collections::ArrayCollection/writeExternal()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ArrayCollection.as:159]
at flash.net::NetConnection/invokeWithArgsArray()
at flash.net::NetConnection/call()
at mx.messaging.channels::NetConnectionChannel/internalSend()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:276]
at mx.messaging.channels::AMFChannel/internalSend()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\channels\AMFChannel.as:364]
at mx.messaging::Channel/send()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\Channel.as:1013]
at mx.messaging.channels::PollingChannel/send()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\channels\PollingChannel.as:365]
at mx.messaging::ChannelSet/send()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\ChannelSet.as:1424]
at mx.messaging::MessageAgent/internalSend()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\MessageAgent.as:1263]
at mx.messaging::Producer/internalSend()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\Producer.as:171]
at mx.messaging::AbstractProducer/send()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\AbstractProducer.as:561]
at mx.rpc::AsyncRequest/invoke()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:153]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::invoke()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:379]
at mx.rpc.remoting::Operation/http://www.adobe.com/2006/flex/mx/internal::invoke()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\remoting\Operation.as:287]
at mx.rpc.remoting::Operation/send()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\remoting\Operation.as:254]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.rpc::AbstractService/http://www.adobe.com/2006/actionscript/flash/proxy::callProperty()[E:\dev\4.x\frameworks\projects\rpc\src\mx\rpc\AbstractService.as:408]
有什么方法可以解决这个问题吗?
详细信息:使用Flex 4.1,使用BlazeDS和Java
这是扩展类:
package
{
import mx.collections.ArrayCollection;
public class NewEntryArrayCollection extends ArrayCollection
{
private var newEntry:Object;
// callback to generate a new entry
public var factoryFunction:Function;
// callback to test if an entry is empty and should be deleted
public var emptyTestFunction:Function;
public function NewEntryArrayCollection(source:Array=null)
{
super(source);
}
override public function getItemAt(index:int, prefetch:int=0):Object
{
if (index < 0 || index >= length)
throw new RangeError("invalid index", index);
if (index < super.length)
return super.getItemAt(index, prefetch);
if (!newEntry)
newEntry=factoryFunction();
return newEntry;
}
override public function get length():int
{
return super.length + 1;
}
override public function itemUpdated(item:Object, property:Object=null, oldValue:Object=null, newValue:Object=null):void
{
super.itemUpdated(item, property, oldValue, newValue);
if (item != newEntry)
{
if (emptyTestFunction != null)
{
if (emptyTestFunction(item))
{
removeItemAt(getItemIndex(item));
}
}
}
else
{
if (emptyTestFunction != null)
{
if (!emptyTestFunction(item))
{
newEntry=null;
addItemAt(item, length - 1);
}
}
}
}
}
}