header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
bumples15
Points:50
Posts:0
Answered

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



1
Andrid
Points: 720
Posts:0
Accepted Answer
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); 



2
bumples15
Points: 50
Posts:0
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

3
Frank_T
Points: 0
Posts:0
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;  
}   



Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 8+5 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions