Copy link to clipboard
Copied
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
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
...Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
'square' would be the instance name. This is the fourth topic about the same code.
Copy link to clipboard
Copied
And...?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Here's are the related posts:
how to drag an object and have its rotation updated
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
You're welcome
Find more inspiration, events, and resources on the new Adobe Community
Explore Now