;

PDA

Click to See Complete Forum and Search --> : Change Colour of Multiple Movie Clips?


andr3w
10-30-2009, 02:31 AM
Hi Guys,

I don't know if this should be in the newbie forum. I certainly should be as I'm a 'total tard' when it comes to Actionscript - I've only recently taken the plunge :)

Here's my question - I hope you can help.

I am using the code below to change the colour of a movie clip and it works fine for a single movie clip:

myInstanceName.addEventListener(MouseEvent.ROLL_OV ER, colourOver);

function colourOver(e:Event){
var myInstanceName:MovieClip = e.target as MovieClip;
changeColor(myInstanceName, 0x999933);
}

The difficulty is I have 10 movie clips and I'd like to change the colour of whatever one I roll over. Is there a way to pass the instance name without explicitly stating it - so I can use the same function for all 10 movie clips?

I have no idea how to do this. I could write 10 functions but that makes me feel really dumb and I can't convert them to buttons.

Any help or suggestions would be great. Thanks guys and gals.

cancerinform
10-30-2009, 06:24 AM
You can see here how to change the color:

http://board.flashkit.com/board/showthread.php?t=803170&highlight=colorTransform

AttackRabbit
10-30-2009, 08:24 AM
Assuming all your clips are located in the same place , so as the function changeColor is available to all , then your code is fine , just add the same listener to all your clips you want to enable with the roll over.

clip1.addEventListener(MouseEvent.ROLL_OV ER, colourOver);
clip2.addEventListener(MouseEvent.ROLL_OV ER, colourOver);
clip3.addEventListener(MouseEvent.ROLL_OV ER, colourOver);

Your e.target , isnt really going to be the instance name of the target , but rather reference to it in the display list. It should work.