This content has been marked as final. Show 9 replies
Not sure I understand the problem... Is the object moved by script? In that case you could change only the _x property, not _y. But I guess there's more to it... what do you mean by 'angle'? You could get the angle between line 2 and the object with some basic trigonometry, but again, I'm not sure what your goal is. Maybe you can explain it more detailed?
Alrighty: I'm simulating the motion of an excavator. During it's motion, it has 3 primary components. The 'boom', the 'stick' and the 'bucket' I'm going to be as detailed as possible about my build.
It'll ask for a u/n and p/w. Use 'guest' for both fields.
The movement is simply done by using the arrow keys to control the playhead inside the yellow and black line. I used a motion tween to restrict the range of movement.
The blue box, is what I'd like to keep 'level' in relationship to the thick black line.
Hope that helps...sometimes a visual reference makes all the difference.
Thanks for the attention....
the bucket will always remain in a vertical (or horizontal depending upon how you look at it) position. the angle between the boom and stick will be 90 degrees minus the angle between the boom and horizontal.
That makes total sense, however since the momevent of the boom and the stick are controlled motion tweens - I can do this if I new how to read the angle of those items ? I know you can get x/y numbers, but can you get an angle of and object? Is that possible?
do you mean:
I have tried that - it can only work if I know how much to rotate it by. As you can see with the animation: the angle varies depending on the postion of the other elements. I could use that if I knew the angle of the yellow line (stick) at every moment. Then with some simple math it could work.
So, the problem is that the amount it has to rotate changes all the time..... so it sort of has to dynamically adjust constantly.....
quite the challenge?
yes, you can get the angle of an object. if you want to know the angle of the line connecting x1,y1 and x2,y2 you can use:
Math.atan2(y1-y2,x1-x2); // this is in radians. multiply by 180/Math.PI for degrees
So, x1 and y1, etc: I have to input those numbers manually? OR can I put a series of blank MC's has hinge points to pull X/Y numbers from?
so it would looke like: Math.atan2(hinge1_y-hinge2_y, hinge1_x-hinge2_x);
I suppose right now I'm really wishing I paid more attention in geometry - which I took something like 14 years ago...
you don't need to enter anything manually and you don't need work-around movieclips at hinge points. i'm not sure how your project is set-up but normally you would have the user control the rotation of the boom (with registration point at its left), the length of the boom and the length of the stick. everything else is calculable (by flash) from there.
for example, you might want to know where to move the stick so it stays at the end of the boom when a user rotates or extends the boom. the sticks _x and _y properties are given by: