Changing cursor color when over another movie clip

Sigh… here I am again with probably-simple questions I just can’t figure out.

Anyways, this time, I have a crosshairs custom-cursor (instance name ‘crosshairs’) that is black, and I want it to turn red whenever it is moved over a target that the user can ‘shoot’ at.

Basically, I am figuring that I simply need to perform a hitTest on the ‘target’ instance and, if it is true, use setRGB to turn the ‘crosshairs’ instance red. However, as of right now, the crosshairs is always black, whether it is over the target or not :frowning:

Soooo… anyone wanna bonk me on the head and tell me what clueless newbie mistakes I’m making this time? :slight_smile:

Thanks all,

  • wobbly

P.S. Oh yeah, and is there any way to make the color change / onMouseDown shooting action occur only when the CENTER of the crosshairs is over the target? Y’know, for realism. Well, anyways, cheerio…

Well on the clip you are rolling Over you can do this…

on (rollOver){
_root.crosshairs.gotoAndStop(2);
}

Where your crosshair is a movie clip, and frames 1 and 2 both have a stop() action. But on frame 2 you have your red cursor.

As for the thing with the center… same concept, but attach the movies center to your mouse (which it should be like that anyway :slight_smile: So that way your mouse pointer will be the center of your crosshair clip and it will always be on the target if you rollOver. And use the same process above but use on (press) instead.

Try something like this:

myStageMC.onMouseMove = function() {
	if (this.hitTest(_root._xmouse, _root._ymouse, false)) {
		Mouse.hide();
		myArrow._visible = true;
		myArrow._x = _root._xmouse;
		myArrow._y = _root._ymouse;
	} else {
		Mouse.show();
		myArrow._visible = false;
	}
	updateAfterEvent(); // Try commenting this line out, and the motion sucks!
};
myStageMC.onMouseUp = function() {
	myArrow.gotoAndStop(1);
};

Hope this helps!

oh lost, replied same time here!

Actually I replied 2 minutes earlier :evil:

And h88, you have to base your solution on the assumption that the person does not know that much AS so they need a more basic way to do it.

Actully, i was testing and coding :stuck_out_tongue:

sorry, but since it was a game, i thought he was quite a good actionscripter, nevermind, l8rzz m8 =)

Hey, lost and h88 - thanks! Both of your solutions are good progress for me.

I -am- really new and I guess I shouldn’t try complex stuff like games until I’m more familiar, but, alas, my habit with new stuff is to just jump in and figure it out as I go. And to be quite honest, I don’t mind more complex solutions like h88’s, because it’s more practice for me figuring out what all he’s doing.

Anyways, just wanted to say thanks for the help :slight_smile: I’m sure I’ll be back to the AS board sometime soon :stuck_out_tongue:

No Pro anyways! :slight_smile:

Just out of curiousity…

I’ve been messing around with alternative ways of doing this, trying to use the Color object. Does anyone want to tell me why this code just does not change the RGB value of my crosshairs when the crosshairs cursor moves over the target? (I am fairly sure this method can work, too, because I have succeeded in accidentally setting the crosshairs RGB value to FF0000 at all times in several of my attempts :P)

// this script is written in the ‘target’ instance’s Actions panel

onClipEvent (enterFrame) {
this.hitTest(_root.crosshairs);
if ((this.hitTest(_root.crosshairs, true))) {
myColor = new Color(_root.crosshairs);
myColor.setRGB(0xFF0000);
}
}

Well, as always, many thanks for all your help! (and patience with my probably frustrating newbie qualities :P)

  • wobblyfork

Hey all -

Hooray! I figured it out myself! Phew… it’s nice to see my brain making SOME progress with this nutty ActionScript… :wink:

Anyhoo… yeah, don’t worry about wasting time you could be doing something better telling me how clueless I am :slight_smile:

As you get into actionscript you become more familiar with it and it isn’t as nutty as it seems…lol.

Well now you haev 2 ways of doing the same thing with your cursor :slight_smile:

Congrats on solving the second problem on your own =)