Unexpected results when using vector.splice on int or a user defined class. Run the attached bug file. Actual: HEllo,Bye,cya,Hi 1,0,3 TypeError: Error #1034: Type Coercion failed: cannot convert __AS3__.vec::Vector.<t.as$1::Rectangle>@102c821 to t.as$1.Rectangle. at Vector$object/_spliceHelper() at Vector$object/_splice() at <anonymous>() at t.as$1:tryRectangle()[t.as:54] at global$init()[t.as:61] Expected: HEllo,Bye,cya,Hi 1,5,6,3 [object Rectangle],[object Rectangle],[object Rectangle],[object Rectangle]
Here's an excerpt of the int sample: var vs:Vector.<int> = new Vector.<int>; vs.push(1); vs.push(2); vs.push(3); var nvs:Vector.<int> = new Vector.<int>; nvs.push(5); nvs.push(6); vs.splice(1, 1, nvs); trace(vs); actual: 1,0,3 expected 1,5,6,3
This is working as expected. Splice takes a rest argument that contains the items to insert into the Vector - it does not do any "expansion" or anything of those items. The int case produces 0, becuase anything can be converted to a number (though the result is almost always NaN, or 0 for int since int doesn't have NaN).
According to the documentation for vector.splice: ... items — An optional list of one or more comma-separated values, or a Vector, to insert into the Vector at the position specified in the startIndex parameter. This seems to clearly indicate that a Vector is an acceptable parameter.
The documentation is wrong - it was copied from Array.splice where this sort of works, but not in the way you expect. I believe there is already a doc bug on this internally.
Test media not required as this is an invalid bug. Also verified that documentation for Argo has been updated (Vector language has been removed): http://river.corp.adobe.com:81/Flash_Argo/standalone/langref/Vector.html#splice%28%29