7/30/2011 8:45:43 PM
Title:
colouring book
I am trying to make a colouring book and I am getting no errors but when I test the movie nothing happens. I have given the colors and the objects all instances. The colors are on the actions layers. I have seperate layers for the three objects. everything looks fine. here is the code that I am using.
import flash.events.MouseEvent;
red_btn.addEventListener(MouseEvent.CLICK, changeColour);
blue_btn.addEventListener(MouseEvent.CLICK, changeColour);
green_btn.addEventListener(MouseEvent.CLICK, changeColour);
function changeColour(evt:MouseEvent) : void{
if (evt.target.name=="red_btn") {
arrow_mc.y=103;
}
if (evt.target.name=="blue_btn") {
arrow_mc.y=196;
}
if (evt.target.name=="green_btn") {
arrow_mc.y=278;
}
}
sky_mc.addEventListener(MouseEvent.CLICK, changeColour);
ground_mc.addEventListener(MouseEvent.CLICK, changeColour);
bigrabbit_mc.addEventListener(MouseEvent.CLICK, changeColour);
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 changeToColour:ColorTransform = new ColorTransform();
changeToColour=red;
function changeColour2(evt:MouseEvent) {
evt.target.transform.colorTransform=changeToColour;
}
any advice would be great as I can't figure out why it is not working and no errors when I test.
thanks. jen
7/31/2011 7:55:28 AM
code seems broken at many places. As far as i understand it should be like this :
the if condition should be
//change the 3 if conditions for each color . I am doing for red only
if (evt.target.name=="red_btn") {
arrow_mc.y=103;
var changeToColour:ColorTransform = new ColorTransform();
changeToColour=red;
}
//here the function called should be changeColour2 not changeColour
sky_mc.addEventListener(MouseEvent.CLICK, changeColour2);
7/31/2011 9:25:15 AM
Thank you, I will try that. I am still in the learning stage of flash and could not figure it out.
Thanks again,
Jen
8/2/2011 10:03:16 AM
I hope this works for you
import flash.events.MouseEvent;
red_btn.addEventListener(MouseEvent.CLICK, changeColour);
blue_btn.addEventListener(MouseEvent.CLICK, changeColour);
green_btn.addEventListener(MouseEvent.CLICK, changeColour);
function changeColour(evt:MouseEvent) : void{
if (evt.target.name=="red_btn") {
arrow_mc.y=103;
var changeToColour:ColorTransform = new ColorTransform();
changeToColour=red;
}
if (evt.target.name=="blue_btn") {
arrow_mc.y=196;
var changeToColour:ColorTransform = new ColorTransform();
changeToColour=blue;
}
if (evt.target.name=="green_btn") {
arrow_mc.y=278;
var changeToColour:ColorTransform = new ColorTransform();
changeToColour=green;
}
}
sky_mc.addEventListener(MouseEvent.CLICK, changeColour2);
ground_mc.addEventListener(MouseEvent.CLICK, changeColour2);
bigrabbit_mc.addEventListener(MouseEvent.CLICK, changeColour2);
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 changeToColour:ColorTransform = new ColorTransform();
changeToColour=red;
function changeColour2(evt:MouseEvent) {
evt.target.transform.colorTransform=changeToColour;
}