Solved

actionscript: change hue

Posted on 2004-04-12
3
1,585 Views
Last Modified: 2008-09-22
I would like to know if there is a function to change the hue of a movie clip on the fly.
0
Comment
Question by:AZAKA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 9

Accepted Solution

by:
krishnaprathab earned 125 total points
ID: 10833891
Hi,

 There is no way by which you can change the hue of the MovieClip on the fly. Unless you write a custom (and ofcourse complex function) which can manipulate the colors and do for you. As far as my knowldge there is no function which does this.

The closest which I was able to find for you was this code at actionscript.org :


//this function acts on normalized values for hue,luminosity,saturation
//numbers between 0-1
hls2rgb=function(h,l,s){
      var r,g,b
      if(!s){
              r=g=b=l
      }else{
            var t1,t2,rt3,gt3,bt3
              if(l<0.5) t2=l*(1.0+s)

              if(l>=0.5){
                  t2=l+s-l*s
                  t1 = (2*l)-t2
            }
            rt3=h+1/3
            if(rt3<0)rt3++
            if(rt3>1)rt3--
            gt3=h
              if(gt3<0)gt3++
              if(gt3>1)gt3--
              bt3=h-1/3
              if(bt3<0)bt3++
              if(bt3>1)bt3--
             if(6*rt3<1){
                  r=t1+(t2-t1)*6.0*rt3
            }else if(2*rt3<1){
                  r=t2
              }else if(3*rt3<2){
                  r=t1+(t2-t1)*((2.0/3.0)-rt3)*6
              }else{
                     r=t1
              }
            if(6*gt3<1){
                  g=t1+(t2-t1)*6.0*gt3
            }else if(2*gt3<1){
                  g=t2
            }else if(3*gt3<2){
                  g=t1+(t2-t1)*((2.0/3.0)-gt3)*6
            }else{
                  g=t1
            }
            if(6*bt3<1){
                  b=t1+(t2-t1)*6.0*bt3
            }else if(2*bt3<1){
                  b=t2
            }else if(3*bt3<2){
                  b=t1+(t2-t1)*((2.0/3.0)-bt3)*6
            }else{
                  b=t1
            }  
      }
      return {r:r,g:g,b:b}
}


/*test it out
hue=90 // 0-360 degrees
luminosity=50 //0-100 percent
saturation=50 //0-100 percent

rgb=hls2rgb(hue,luminosity/100,saturation/100)
r=rgb.r*255 //convert back to range
g=rgb.g*255 //convert back to range
b=rgb.b*255 //convert back to range
hex=r<<16|g<<8|b //convert to hex for use with color object*/
 
Let me know if this helped !

Thanks,
KP
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question