Help with colouring in game
Hey I'm creating an number of games for my HSC major project and I'm having trouble with creating a colouring in book. This is the code I have:
red_btn.addEventListener(MouseEvent.CLICK, pickColour);
white_btn.addEventListener(MouseEvent.CLICK, pickColour);
blue_btn.addEventListener(MouseEvent.CLICK, pickColour);
green_btn.addEventListener(MouseEvent.CLICK, pickColour);
function pickColour(evt:MouseEvent) {
if (evt.target.name=="red_btn") {
arrow_mc.y=133;
}
if (evt.target.name=="white_btn") {
arrow_mc.y=179;
}
if (evt.target.name=="blue_btn") {
arrow_mc.y=221;
}
if (evt.target.name=="green_btn") {
arrow_mc.y=264;
}
}
middle_mc.useHandCursor=true;
middle_mc.buttonMode=true;
reflection1_mc.useHandCursor=true;
reflection1_mc.buttonMode=true;
reflection2_mc.useHandCursor=true;
reflection2_mc.buttonMode=true;
middle_mc.addEventListener(MouseEvent.CLICK, changeColour);
reflection1_mc.addEventListener(MouseEvent.CLICK, changeColour);
reflection2_mc.addEventListener(MouseEvent.CLICK, changeColour);
function changeColour(event :MouseEvent) : void
{
trace(event.target.name);
event.target.transform.colorTransform=changeToColo r;
}
var red:ColorTransform = new ColorTransform(0,0,0,0,255,0,0,255);
var blue:ColorTransform = new ColorTransform(0,0,0,0,0,0,255,255);
var green:ColorTransform = new ColorTransform(0,0,0,0,0,255,0,255);
var white:ColorTransform = new ColorTransform(0,0,0,0,255,255,255,255);
var changeToColor:ColorTransform = new ColorTransform();
changeToColor=red;
function pickColor(evt:MouseEvent) {
if (evt.target.name=="red_btn") {
changeToColor=red;
arrow_mc.y=133;
}
if (evt.target.name=="white_btn") {
changeToColor=white;
arrow_mc.y=179;
}
if (evt.target.name=="blue_btn") {
changeToColor=blue;
arrow_mc.y=221;
}
if (evt.target.name=="green_btn") {
changeToColor=green;
arrow_mc.y=264;
}
}
It works although when I test the movie no matter what colour the player chooses it always colours in red, I have no idea why this is happening can someone please help?