View Full Version : Changing cursor color when over another movie clip
WobblyFork
November 16th, 2002, 12:50 PM
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 :(
Soooo... anyone wanna bonk me on the head and tell me what clueless newbie mistakes I'm making this time? :)
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...
lostinbeta
November 16th, 2002, 01:08 PM
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 :-\) 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.
h88
November 16th, 2002, 01:10 PM
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!
h88
November 16th, 2002, 01:11 PM
oh lost, replied same time here!
lostinbeta
November 16th, 2002, 01:11 PM
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.
h88
November 16th, 2002, 01:12 PM
Actully, i was testing and coding :P
h88
November 16th, 2002, 01:14 PM
sorry, but since it was a game, i thought he was quite a good actionscripter, nevermind, l8rzz m8 =)
WobblyFork
November 16th, 2002, 01:54 PM
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 :) I'm sure I'll be back to the AS board sometime soon :P
h88
November 16th, 2002, 01:57 PM
No Pro anyways! :)
WobblyFork
November 17th, 2002, 11:27 AM
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
WobblyFork
November 17th, 2002, 12:02 PM
Hey all -
Hooray! I figured it out myself! Phew... it's nice to see my brain making SOME progress with this nutty ActionScript... ;)
Anyhoo... yeah, don't worry about wasting time you could be doing something better telling me how clueless I am :)
lostinbeta
November 17th, 2002, 03:12 PM
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 :)
Congrats on solving the second problem on your own =)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.