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

Code is not accessing array

Participant ,
Oct 06, 2015 Oct 06, 2015

Copy link to clipboard

Copied

I have an array that holds the animations for a character MovieClip. On the first frame there is code which accesses this array (both are on the same layer and frame)

var attackList: Array = new Array();

attackList.push('dashBurst', 'punch');

curAnim = attackList[randomCalc(0, attackList.length)];

curAnim exists and can be defined in a different way.

By using trace statements I determined that flash was not getting any index at all from attackList. I tried attackList[0] and [1] and both threw the same error.

TypeError: Error #1009: Cannot access a property or method of a null object reference.

randomCalc is just a function that generates a random whole number between two values.

Why am I getting this error?

TOPICS
ActionScript

Views

285

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

Participant , Oct 06, 2015 Oct 06, 2015

I got it now.

On the main timeline there was a line telling the MovieClip to skip that frame.

Oops.

Votes

Translate

Translate
Participant ,
Oct 06, 2015 Oct 06, 2015

Copy link to clipboard

Copied

I just found out that none of my Arrays are able to be accessed at all.

What am I doing wrong?

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
Participant ,
Oct 06, 2015 Oct 06, 2015

Copy link to clipboard

Copied

Adding more trace statements shows that none of the arrays, variables, import statements, or anything are being run.

???

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
Participant ,
Oct 06, 2015 Oct 06, 2015

Copy link to clipboard

Copied

I got it now.

On the main timeline there was a line telling the MovieClip to skip that frame.

Oops.

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
Explorer ,
Oct 06, 2015 Oct 06, 2015

Copy link to clipboard

Copied

LATEST

See Array - Adobe ActionScript® 3 (AS3 ) API Reference‌, maybe you should use " instead '.

var attackList: Array = new Array();

attackList.push("dashBurst", "punch");

Or try another way:

var attackList: Array = new Array("dashBurst", "punch");

Hope this help!

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