3 Replies Latest reply on Nov 26, 2007 7:14 AM by clbeech

    Dynamic filll color

      Hi all,

      I am working on a project where i have drawn a simple character using Flash's drawing tools, I have grouped the different body parts into their own movie clips so i can deal with them separately in actionscript.

      What I want to do is let the user define the color of the character - so i need to dynamically change the fill color of each body part according to a set variable. I thought I would use something like this for each seperate body part:

      color = new Color(move_clip_name);

      This code does work - but it changes the color of the entire movie clip - stroke lines and all - So i end up with a solid shape of the defined color, but the drawing lines get changed to that colour as well.. lets just say its not pretty. I have tried making just the fill a movie clip, within a movie clip - but this seems to make the code above stop working - the color doesn't change.

      Is there a way of changing just the fill color of a shape, and keeping the stroke lines black? and if anybody can think of a different solution to the problem of changing all the fill colors at once, it would be muchly apprechiated.

      Thanks Everyone!

        • 1. Re: Dynamic filll color
          robdillon Most Valuable Participant
          What you have done should work. Be sure that you are correctly targeting the clip that you want to change. If the code remains in the same place and you now want to change a clip that is inside another clip, be sure that your path to that inner clip is correct.
          • 2. Re: Dynamic filll color
            goatus Level 1
            Thanks Rob.

            Seems I was targeting the movieclip incorrectly.. for anyone that is interested the code for the movieclip fill inside a movieclip was meant to be:

            color = new Color(movieclip1.movieclip2);

            Where movieclip2 is the movieclip we are changing the color of, and movieclip1 is the parent movieclip, which movieclip2 is inside of.

            A follow up question...

            Is there a way to target the original movieclip, and not just an instance of the movieclip. ie, I want to set the color of every instance of a movieclip called 'movie' - can i target the movieclip itself, or must I target each of the instances of that movie clip independently?

            Cheers for all the help, great forum!

            • 3. Re: Dynamic filll color
              clbeech Level 3
              you can only target and make changes to a MC that is currently available on the timeline. But if all of the instances are named 'movie' then targeting that instance name should make the change to all. However, if they are appended with a number (like above) you will need to add that to the names string, you could then use a loop to target them. I would also consider placing the color change code within a method that you can call on each MC when needed, you could also construct this as a prototype. all together it would look something like this: