0

For a while now in my app I've used ObjectUtil.copy to copy array collections. Recently we've been making a lot of changes to the app and its started breaking on any of my copy commands. I originally thought it was due to custom classes in the arrays but ruled that out by testing empty or simple ArrayCollections.

Neither of these will work for me:

var a:ArrayCollection = ObjectUtil.copy(new ArrayCollection());
newWindow.months = ObjectUtil.copy(months) as ArrayCollection;

In the second line, newWindow is just a new canvas I'm going to show with a 'months' property and months is an ArrayCollection with only strings in it.

Inside the .copy() function it breaks on buffer.writeObject(value); and throws this error 'ArgumentError: Error #2004: One of the parameters is invalid.'

ScottF
  • 565
  • 6
  • 21

1 Answers1

0

Copy source array

newWindow.months = new ArrayCollection(ObjectUtil.copy(months.source) as Array);
Timofei Davydik
  • 7,244
  • 7
  • 33
  • 59
  • I'll give that a try. I'm confused as to why I wouldn't be able to do a copy of the ArrayCollection though. I didn't have a problem with it before and there are tons of examples with it working that way online. – ScottF Apr 05 '13 at 21:17