Skip to main content
Inspiring
April 6, 2012
Answered

ReferenceError: Error #1037: Cannot assign to a method every on Array.

  • April 6, 2012
  • 1 reply
  • 1566 views

This code causes a runtime Error#1037 when publishing in AS3, but not in AS2.

var myArray:Array=[];

myArray["every"]=[];

I'm guessing that is because every is an already defined method in the Array class.

Should I be using the dictionary class instead? Any good tips on that? Anything I should really know?

This topic has been closed for replies.
Correct answer kglad

i'm not sure what you're trying to do but the Array class is used for ordered lists.  You should NOT be using a string for a key.

if you want to create an unordered list = hash=map in flash (and use strings for keys), use an object:

var obj:Object={}

obj["every"]=[];  // if you want the value to be an array or

obj["ever"]={};  // if you want the value to be another object/has/map

use a dictionary if you want to use objects for keys.

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
April 6, 2012

i'm not sure what you're trying to do but the Array class is used for ordered lists.  You should NOT be using a string for a key.

if you want to create an unordered list = hash=map in flash (and use strings for keys), use an object:

var obj:Object={}

obj["every"]=[];  // if you want the value to be an array or

obj["ever"]={};  // if you want the value to be another object/has/map

use a dictionary if you want to use objects for keys.

RothrockAuthor
Inspiring
April 9, 2012

I guess bad old got away with it in AS2 habits die hard. Thanks.