From 5df1335471a3953c9efc91c692893f03c4602d34 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Thu, 23 Apr 2009 00:30:44 +0000 Subject: [PATCH] Add an easy way to initialize. Jeez, this whole thing could *almost* go away if we moved to flash 10 and used Vector, but of course, there's no way to get the type of Vector. Maybe there is, with describeType(). Can't experiment now. I'd fall out of my chair if there were. We need to know in case sending an empty array to the server, it's still gotta be the right type (with non-empty we could try examining the first element). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5742 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/as/com/threerings/io/TypedArray.as | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/as/com/threerings/io/TypedArray.as b/src/as/com/threerings/io/TypedArray.as index 0e7653ad6..7d85f93a2 100644 --- a/src/as/com/threerings/io/TypedArray.as +++ b/src/as/com/threerings/io/TypedArray.as @@ -55,9 +55,13 @@ public dynamic class TypedArray extends Array /** * A factory method to create a TypedArray for holding objects of the specified type. */ - public static function create (of :Class) :TypedArray + public static function create (of :Class, initialValues :Array = null) :TypedArray { - return new TypedArray(getJavaType(of)); + var ta :TypedArray = new TypedArray(getJavaType(of)); + if (initialValues != null) { + ta.addAll(initialValues); + } + return ta; } /**