Note that there are some explanatory texts on larger screens.

plurals
  1. POExtending an ArrayCollection causes remoting to fail
    text
    copied!<p>I need to extend an ArrayCollection in Flex to implement something like <a href="http://blogs.adobe.com/aharui/2008/03/custom_arraycollections_adding.html" rel="nofollow">this</a>. But when I send it to the server, it appears that the serialization fails.</p> <pre><code>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] </code></pre> <p>Is there any way to work around this?</p> <p>Details: Using Flex 4.1, with BlazeDS and Java</p> <p>This is the extended class:</p> <pre><code>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 &lt; 0 || index &gt;= length) throw new RangeError("invalid index", index); if (index &lt; 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); } } } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload