I've made a new question since it makes sense since the problem isn't the same anymore.
I'm making a colouring game. CanvPark_mc is the Movieclip with the details of creating the canvas and where all the brush details are located. The Huge, Medium and SmallSelected1 variables, are variables that are changed when you click the brushes, so you're able to identify them.
I want to switch cursors depending on the brush that was last clicked. This can be done through the first if paramenters. Right now, this is my code to switch, thanks to the help of @NBooo in the previous question
var cursor_mc: MovieClip = new MovieClip();
if (CanvPark_mc.HugeSelected1 == true) {
cursor_mc = cursor1_mc; //Big Cursor
removeChild(cursor_mc);
}
if (CanvPark_mc.MediumSelected1 == true) {
cursor_mc = cursor2_mc; //Medium Cursor
removeChild(cursor_mc);
}
if (CanvPark_mc.SmallSelected1 == true) {
cursor_mc = cursor3_mc; //Small Cursor
removeChild(cursor_mc);
}
stage.addEventListener(MouseEvent.MOUSE_MOVE, moveCursor);
function moveCursor(myEvent: MouseEvent) {
if (CanvPark_mc.SmallSelected1 == false && CanvPark_mc.MediumSelected1 == false && CanvPark_mc.HugeSelected1 == false) {
Mouse.cursor = "auto";
} else if (cursor_mc){
addChild(cursor_mc);
setChildIndex(cursor_mc, this.numChildren - 1);
cursor_mc.x = stage.mouseX;
cursor_mc.y = stage.mouseY;
cursor_mc.mouseChildren = cursor_mc.mouseEnabled = false;
Mouse.hide();
}
}
The problem with this code, unfortunately, is that, whenever I click the said buttons, the cursor disappears. It doesn't change itself to any of the MovieClips I previously made.
Note that the removeChild in the if blocks is there in hopes of removing previous instances of cursor_mc on the screen after clicking them in the past.
In tests, it only changes, in the first if blocks, one of the parameters has a = instead of ==.
Example :
if (CanvPark_mc.HugeSelected1 == true) {
cursor_mc = cursor1_mc; // Big Cursor
removeChild(cursor_mc);
}
if (CanvPark_mc.MediumSelected1 == true) {
cursor_mc = cursor2_mc; //Medium Cursor
removeChild(cursor_mc);
}
if (CanvPark_mc.SmallSelected1 = true) {
cursor_mc = cursor3_mc; //This is the one he'll run, showing the smallest cursor
removeChild(cursor_mc);
}
In addition, if they are all reduced down to just =, the code will opt for the last if in the list. I think there's a problem with my code and I can't tell what it is after hours of trying.
Could any of you help me figure this out?