From the help:
Example
The following code creates the Array object
vegetables with the elements [spinach, green pepper,
cilantro, onion, avocado]. The splice() method is then
called with the parameters 2 and 2, which assigns cilantro and
onion to the spliced array. The
vegetables array then contains [spinach,green
pepper,avocado]. The splice() method is called a second time
using the parameters 1, 0, and the spliced array to assign
[spinach,cilantro,onion,green pepper,avocado] to
vegetables.
var vegetables:Array = new Array("spinach",
"green pepper",
"cilantro",
"onion",
"avocado");
var spliced:Array = vegetables.splice(2, 2);
trace(vegetables); // spinach,green pepper,avocado
trace(spliced); // cilantro,onion
vegetables.splice(1, 0, spliced);
trace(vegetables); // spinach,cilantro,onion,green pepper,avocado
However, this is not the case. When you pass an array as the third argument to splice, it adds the target ARRAY to the original array. It does not insert the VALUES in the target array.
if you add
for each (var o:Object in vegetables)
trace(typeof(o), o.toString());
you will get:
string spinach
object cilantro,onion
string green pepper
string avocado
So, is this a bug or intended behavior? I could see how it could go either way. However, it seems the example in the documentation should be fixed. I'm thinking it was intended that a passed-in array would be disassembled and its components added. Otherwise, why say "one or more comma-separated values, or an array, to insert into the array"? Singling out array makes no sense, as it would be treated like any other value passed in.
--
Jason
__._,_.___
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
![]()
SPONSORED LINKS
| Software development tool | Software development | Software development services |
| Home design software | Software development company |
Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe
__,_._,___

