I'm working on a painting game, that once you click on the brushes, the mouse switches to the graphical counterpart of said brushes and will let you paint on screen. If no brush has been selected, the mouse will remain the same.
The Rectangle and the brushes are on a separate Movieclip, which allows me to layer png lines over it so you can fill in and draw.
In the actions layer in the Scene 1, this is my code for changing the mouse:
var cursor_mc:MovieClip;
if (CanvPark_mc.HugeSelected1 == true){
cursor_mc = cursor1_mc;
}else if(CanvPark_mc.MediumSelected1 == true) {
cursor_mc = cursor2_mc;
}else if(CanvPark_mc.SmallSelected1 == true) {
cursor_mc = cursor3_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{
setChildIndex(cursor_mc, this.numChildren-1);
cursor_mc.x = (mouseX);
cursor_mc.y = (mouseY);
Mouse.hide();
}
}
Each brush has a boolean variable associated to it: Small, Medium and HugeSelected1, so that way, I can tell at all times in code which one is selected and which one isn't.
Right now, running this code, in the start, nothing happens, but if I click any of the brushes, this pops up in the output.
TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/setChildIndex()
at visibilityToggle/moveCursor()[visibilityToggle::frame1:42]
Seems to be pointing specifically at
setChildIndex(cursor_mc, this.numChildren-1);
I honestly don't know what's causing this error. I thought it would be this straight forward to change my mouse cursor.
How can I fix this?