Copy link to clipboard
Copied
Hi, I'm trying to make a game so testing out a lot of interactions between different objects and time frames.
Currently, I have a red box and a green box. I wrote some keyboard listeners and the green box can move left and right
with the left/right arrow keys (the code is inside the object (green).(pic1)
I have a red box that moves up and down with a tween(pic2) and once it reaches the end of the tween, it loops back
to the beginning. If (notice == true) on frame 21 however, it will go to the next frame, where it will become blue and stop on that frame.
With my trace, I know the hitTest works and produces true when the green and red box overlap, however:
Goal: My goal is to make it so when the green box touches(with hitTestObject) the red box, the variable notice becomes true
and when the red box reaches frame 21, (notice == true) becomes true and goes to frame 22.
Question: I guess the ultimate question is how I can assign an attribute/variable to an object, and be able to retrieve the
value of that attribute/variable from both inside or outside the object.
Thanks
If I'm reading this correctly, then the solution is simple: any property of an object, custom or not, can be referenced through the object. So, if the object "red" is on the main timeline and you want a property of "red", then you can get to that property from the main timeline as you show: red.objectName. If you want to get to the property from within another timeline, you need to path your way to the object. So, if I'm reading this correctly, the object green contains code that you want to use
...Copy link to clipboard
Copied
If I'm reading this correctly, then the solution is simple: any property of an object, custom or not, can be referenced through the object. So, if the object "red" is on the main timeline and you want a property of "red", then you can get to that property from the main timeline as you show: red.objectName. If you want to get to the property from within another timeline, you need to path your way to the object. So, if I'm reading this correctly, the object green contains code that you want to use to refer to the property in red. So, to get to red from green you will need to move "up" one level in the timeline structure. So it should be something like: MovieClip(parent).red.objectName.
Does that help, or make it worse?
Copy link to clipboard
Copied
Yes, that's exactly what I was looking for. Thanks!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now