How could I get an arrow to follow a movie clip?

Is there anyway to make an arrow point to a moving movie clip, besides moving the arrow every frame?

Umm…give more detail…Im not 100% sure what you mean.

like a little moving movie clip… lets use ‘~’ for now… then there would be an arrow at the bottom of the movie, and as ‘~’ moved, the arrow would keep pointing to it.

[edit=oops, it didnt save the spaces…]
something like that…

just thought of a good way to explain it…
its like those movies that have the eyes following your cursor, but I want the eyes to be an arrow, and follow a movie clip instead…

You get the angle between your clip and the clip you want to follow (with Math.atan2) and then you set the angle. If you know your trigonometry, it’s a walk in the park.

pom 0]

heh… sorry, Im just now passing Pre-Algebra (7th Grade)… can someone explain to me in a little more detail? :lol:

Something like in there : pub40.ezboard.com/fkirupa…3331.topic

pom 0]

hmmm… still doesnt seem to like me… any chance someone could try and make a .fla where it follows a clip instead of the mouse… or make it follow the mouse and explain how to make it follow the clip :lol:

Ok, here’s what you need : in the first frame of your animation

 MovieClip.prototype.follow = function (destx,desty) {
&nbsp &nbsp &nbsp &nbsp // destx is the x coordinate of what you want to follow
&nbsp &nbsp &nbsp &nbsp // same for y
&nbsp &nbsp &nbsp &nbsp var distx = destx - this._x ;
&nbsp &nbsp &nbsp &nbsp var disty = desty - this._y ;
&nbsp &nbsp &nbsp &nbsp var angle = Math.atan2(disty,distx) ; //angle in radians
&nbsp &nbsp &nbsp &nbsp angle *= 180/Math.PI ; //angle in degrees
&nbsp &nbsp &nbsp &nbsp this._rotation = angle ;
}

Then if you want a movie clip to follow the mouse, it’s

 onClipEvent (enterFrame) {
&nbsp &nbsp &nbsp &nbsp follow (_root._xmouse,_root._ymouse) ;
}

If you want it to follow the clip ** guide** that is in _root, it will be

 onClipEvent (enterFrame) {
&nbsp &nbsp &nbsp &nbsp follow (_root.guide._x,_root.guide._y) ;
}

pom 0]

got it to work!! :smiley: Thanks pom :smiley:

Prototypes rock, don’t they ?? :smiley:

pom 0]