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

error on array declaration

Community Beginner ,
Jul 06, 2017 Jul 06, 2017

What am I doing wrong? I don't see it.This array gives me an error message   1120:Access of undefined property square

var shape:Array =[square, rectangle, triangle];

Thank you for your help

TOPICS
ActionScript
566
Translate
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

LEGEND , Jul 09, 2017 Jul 09, 2017

If you answer all of the questions I asked we might be able to proceed.  I suspect your answer to "How is it named "square"?" might get somewhere as not naming it properly (via the instance name field, assuming it is manually created) will produce the error you indicate.

If you are going to show code, make sure it is code relative to your problem and not code that you based your code on.  Colin's code probably works for what it is supposed to be accomplishing.  Whatever you did to try to modify i

...
Translate
LEGEND ,
Jul 07, 2017 Jul 07, 2017

What is square?  How is it created? Where does it exist relative to the code?  How is it named "square"?  I suspect the same problem will arise with the other two once you resolve the problem with square.

Translate
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 ,
Jul 07, 2017 Jul 07, 2017

'square' would be the instance name. This is the fourth topic about the same code.

Translate
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 ,
Jul 07, 2017 Jul 07, 2017

And...? 

Translate
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 ,
Jul 07, 2017 Jul 07, 2017

Was thinking to not answer this exact question here because it won't matter after the other topics are followed. It isn't exactly a duplicate post, but it is about the same code.

Translate
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 ,
Jul 07, 2017 Jul 07, 2017

I'd like to play thru if you don't mind.  I think my questions might be relevant, but only if the person with the issue answers them.

Translate
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 ,
Jul 07, 2017 Jul 07, 2017
Translate
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 ,
Jul 07, 2017 Jul 07, 2017

Ana Maria,

If you answer my questions I will try to help you.

If Colin keeps doing it there is no hope of me helping you.

Translate
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
Community Beginner ,
Jul 08, 2017 Jul 08, 2017

I'm sorry, I did not mean to ignore you, I did not have the chance to check until today.

I was trying to reproduce an example that Colin made with a single object and make it work with an array of objects. I created a square, a triangle and a rectangle. I import the images instead of creating them in animate(not sure if that makes a difference). make them movie clips and declare the array var shape:Array =[square, rectangle, triangle]; and when I try it out it gave that error message. And you are right the error is not just for square, but for all the objects.

var shape:Array = [square,triangle,rectangle];

for (var i = 0; i < shape.length; i++)

shape.buttonMode = true;

here is Colin's code where I replace every instance of shape with shape did not work so I tried replacing it with event.target, it did not work either.  Colin created something else, but I will not be able to try it until Monday as I do not have access to the software right now.  Thank you.

import flash.events.MouseEvent;

shape.addEventListener(MouseEvent.MOUSE_DOWN, pressed);

var rotationValue: Number = shape.rotation;

var startMouseAngle: Number;

function pressed(e: MouseEvent) {

  var dx: Number = e.stageX - shape.x;

  var dy: Number = e.stageY - shape.y;

  startMouseAngle = Math.atan2(dy, dx) * 180 / Math.PI;

  rotationValue = shape.rotation;

  stage.addEventListener(MouseEvent.MOUSE_MOVE, updaterot);

  stage.addEventListener(MouseEvent.MOUSE_UP, stoprot);

}

function updaterot(e: MouseEvent) {

  var dx: Number = e.stageX - shape.x;

  var dy: Number = e.stageY - shape.y;

  shape.rotation = rotationValue + Math.atan2(dy, dx) * 180 / Math.PI - startMouseAngle;

}

function stoprot(e: MouseEvent) {

  stage.removeEventListener(MouseEvent.MOUSE_MOVE, updaterot);

  stage.removeEventListener(MouseEvent.MOUSE_UP, stoprot);

}

Translate
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 ,
Jul 09, 2017 Jul 09, 2017

If you answer all of the questions I asked we might be able to proceed.  I suspect your answer to "How is it named "square"?" might get somewhere as not naming it properly (via the instance name field, assuming it is manually created) will produce the error you indicate.

If you are going to show code, make sure it is code relative to your problem and not code that you based your code on.  Colin's code probably works for what it is supposed to be accomplishing.  Whatever you did to try to modify it is what matters.  In any case, all of that code is likely irrelevant to the error.

Translate
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
Community Beginner ,
Jul 17, 2017 Jul 17, 2017

Thank you for your answer. I am sorry, I did not answer earlier, but I just got to try today.

You were right, I had made a mistake, when I type the instance name. It was capitalize.

Translate
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 ,
Jul 18, 2017 Jul 18, 2017
LATEST

You're welcome

Translate
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