Forum ActionScript 3.0 how to link my brush to pick color + correct sprite use

Problems and discussions relating to ActionScript 3.0 here.

how to link my brush to pick color + correct sprite use

Postby niqM » August 27th, 2012, 4:58 am

Hi guys, i am working on a coloring game here. i really dont know how to code to link my brush (i hide the mouse and use brush) to pick color from color boxes upon mouse click and then use the color to paint a cartoon character. I use sprite on the character so that i can paint the body parts using different colors. i use flash cs3 . Please help me.. i'm really clueless and desperately need your help :( . thank you :)


import flash.display.MovieClip;
import flash.display.Sprite;


const RED:uint = 0xFF0000;
const BLUE:uint = 0x0000FF;
const GREEN:uint = 0x00FF00;

//var brush:MovieClip;
var colorRing:MovieClip = brush.colorRing;
/*var b1:MovieClip;
var b2:MovieClip;
var b3:MovieClip;
//var c:MovieClip;

var curr:MovieClip;
var ct:ColorTransform;

var array:Array = [{button:b1, color:GREEN},
                   {button:b2, color:RED},
                   {button:b3, color:BLUE}];
for each (var obj in array)
    var b:MovieClip = obj.button as MovieClip;

    b.color = obj.color;
    ct = b.transform.colorTransform;
    ct.color = b.color;
    b.transform.colorTransform = ct;

    b.buttonMode = true;
    b.mouseChildren = true;
    b.addEventListener(MouseEvent.CLICK, chooseColour);

var c:Sprite = new Sprite();
c.addEventListener(MouseEvent.CLICK, pickColor);
brush.stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseBrush);

function chooseColour(event:MouseEvent):void
    curr = as MovieClip;

    ct = curr.transform.colorTransform;
    ct.color = curr.color;
    brush.colorRing.transform.colorTransform = ct;


function pickColor(event:MouseEvent):void
{ for (var i:int = 0; i < c.numChildren; i++) {
    if (curr)
        ct = c.getChildAt(i).transform.colorTransform ;
        ct.color = curr.color;
        c.getChildAt(i).transform.colorTransform = ct;

        trace("choose a color first!");

function mouseBrush(event:MouseEvent):void
    brush.x = mouseX;
    brush.y = mouseY;

Posts: 1
Joined: August 27th, 2012, 4:54 am

Return to ActionScript 3.0