2 Replies Latest reply on Apr 29, 2010 12:40 PM by alice_data

    Interpolate() Examples?

    alice_data Level 1

      Hi,

        I wonder what kind of class(es) I should use to accomplish this task. I have two predefined colors, 0xFF0000 and 0x00FF00 (red and green), and I would like to set a number of gradiants of colors between these two colors.

       


      I did come up with something like:

       

      public function setColorScale(num:Number):void{
        
         randomNumber = num;
         randomNumber = Math.floor(Math.random()* (0x1 + 0xFF0000 - 0x00FF00)) + 0x00FF00;
         trace("Set Color Scale " + randomNumber.toString(16));
         randomColors.push(randomNumber.toString(16));

       

        }

       

      However, the colors do not seem to be valid. I looked at interpolate color examples, is this supposed to give you colors between the two colors by any chance? If so, can anyone please suggest an example I can look at?

       

      Thanks for your help.

       

      Alice

        • 1. Re: Interpolate() Examples?
          ShankarFlex3 Level 2

          Hi,

           

          Have you seen this example http://graphics-geek.blogspot.com/2009/07/video-color-my-world.html.

           

           

          Regards,

          Shankar.

          • 2. Re: Interpolate() Examples?
            alice_data Level 1

            The weird thing is, I do have Flash Player 9 on my machine, but I cannot see anything other than some of the text on the page you sent me. It looks like that page has some app issues.

             

            Just curious, this is what I have now:

             

            public function setColorScale(num:Number):void{
                       
                        randomNumber = num;
                        randomNumber = Math.floor(Math.random()* (0x1 + 0xFF0000 - 0x00FF00)) + 0x00FF00;
                        trace("Set Color Scale " + randomNumber.toString(16));
                        randomColors.push(randomNumber.toString(16));
                    }

             

            For some reason, this is the ouput that I get, which the color is black, probably because this is not a valid color. The ouput I got looks something like this: Set Color Scale d7ebb from my trace, and that is output as black.

            I wonder what is up with this? I do have import flash.geom.*; in my class declaration.

             

            Thanks for your help.

             

            Alice