A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Change Colour of Multiple Movie Clips?

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    1

    Change Colour of Multiple Movie Clips?

    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.

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    You can see here how to change the color:

    http://board.flashkit.com/board/show...colorTransform
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    rabid_Delineator AttackRabbit's Avatar
    Join Date
    Dec 2003
    Location
    Orlando, Florida
    Posts
    481
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center