• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

LEGEND ,
Apr 06, 2012 Apr 06, 2012

Copy link to clipboard

Copied

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?

TOPICS
ActionScript

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 06, 2012 Apr 06, 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.

Votes

Translate

Translate
Community Expert ,
Apr 06, 2012 Apr 06, 2012

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 09, 2012 Apr 09, 2012

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines