Skip navigation
Currently Being Moderated

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

Apr 6, 2012 3:16 PM

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?

 
Replies
  • kglad
    72,328 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 6, 2012 3:45 PM   in reply to Rothrock

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points