9 Replies Latest reply on May 15, 2006 12:19 PM by Soc4me3

    Filling shapes

    Soc4me3
      Hi,
      I have a basic shape drawn using the drawing tools. Let's say it is a circle with a blue fill. I wanted to set the blue fill as a variable and have it change colors when someone clicks a button. The only thing I have found is the beginFill() which I think starts a fill from scratch. I already have a fill but just want to change the color. Can anyone help me thanks.
      Chris
        • 1. Re: Filling shapes
          samdl1
          it sounds like you just want to swap old for new and leave it at that if that is the case you can load each graphic into movieclips, placing them on stage at the same position (its neatest if they are in different layers). Name the instances and then in your actionscript place

          second_mc.visible = false;
          my_btn.onRelease = function() {
          first_mc.visible = false;
          second_mc.visible = true;
          }

          bear in mind this will only work one way, pressing the button again will have no effect.

          If this doesnt really answer your question please post more info about your application so we can better answer your question

          Sam
          • 2. Re: Filling shapes
            Level 7
            I think your best bet is to have your circle clip consist of two different
            clips - an outline, and a fill. Then you can use the ColorTransform class to
            change the color of the fill clip.

            --
            Dave -
            Adobe Community Expert
            www.blurredistinction.com
            www.macromedia.com/support/forums/team_macromedia/


            • 3. Re: Filling shapes
              Soc4me3 Level 1
              Sorry, could you be more specific with the ColorTransform class. I am unfamiliar with it. Just to summarize I have a shape I drew and have it filled with a color. I wanted to set the fill to a variable and change the color of the variable. I don't think this can be done but I'm sure there is an alternate way.
              • 4. Re: Filling shapes
                samdl1 Level 1
                ColourTransofm dynamically changes the colour NOT swapping already made instances...his post said that he had one he wanted to use.

                That said, ColourTransform is easy to use, just have a look at the frlash help for a very good explaination

                Sam
                • 5. Re: Filling shapes
                  Level 7
                  You can read in the Help all about ColorTransform. I get what you want to
                  do, and using ColorTransform is your best bet.

                  --
                  Dave -
                  Adobe Community Expert
                  www.blurredistinction.com
                  www.macromedia.com/support/forums/team_macromedia/


                  • 6. Re: Filling shapes
                    Level 7
                    >>NOT swapping already made instances...his post said that he had one he
                    >>wanted to use.

                    His post said nothing of swapping instances, only of chaging color. I think
                    you suggested swapping actually.


                    --
                    Dave -
                    Adobe Community Expert
                    www.blurredistinction.com
                    www.macromedia.com/support/forums/team_macromedia/


                    • 7. Re: Filling shapes
                      Soc4me3 Level 1
                      Yes, I only want to change the color of a graphic shape I drew NOT using action script. I do not want to swap instances. I'm confused how ColorTransform works
                      • 8. Re: Filling shapes
                        blemmo Level 1
                        See the Help file for Transform.colorTransform: http://livedocs.macromedia.com/flash/8/main/00002836.html.

                        Basically, it goes like this:
                        --
                        import flash.geom.*;

                        var trans:Transform = new Transform(theMC);
                        var newColorTransform:ColorTransform = new ColorTransform(0, 0, 0, 1, r, g, b, 0);
                        // change r,g,b to the new color values, e.g. 0, 255, 0 for green color
                        trans.colorTransform = newColorTransform;
                        // assigns new color to 'trans', which changes the color of the MC associated to 'trans'
                        --

                        hth,
                        blemmo
                        • 9. Re: Filling shapes
                          Soc4me3 Level 1
                          Thank you blemmo. I appreciate your time and everyone elses. I'm pretty sur eI can use the information I have learned to do what I want