hey I’m creating a colouring in game for my HSC major project and
was following a tutoral that gave me this code:
import flash.events.MouseEvent;
back2colour.addEventListener(MouseEvent.CLICK, buttndow);
function buttndow(event:MouseEvent):void{
gotoAndStop(“36”);
}
//Colouring in set up
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(evt:MouseEvent) {
trace(evt.target.name);
}
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;
}
}
function changeColour(evt:MouseEvent) {
evt.target.transform.colorTransform=changeToColor;
}
and I get the error 1021: duplicate function definition. I’m new to flash and actionscript 3.0 so could anyone help me out. I think its because I have this:
function changeColour(evt:MouseEvent) {
trace(evt.target.name);
and this:
function changeColour(evt:MouseEvent) {
evt.target.transform.colorTransform=changeToColor;
I’ve tried putting them in the same function but that didn’t work and I tried making it a completely different name but that just made other errors occur. I really need help. I have no idea what I’m doing.