A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: How change tint on mc rollover using AS3

  1. #1
    Junior Member
    Join Date
    Nov 2007
    Posts
    27

    How change tint on mc rollover using AS3

    Apologies if this is an old question, but I found no answers after scouring the web. I have a movie clip I've placed with actionscript 3. I currently have the code set to change the alpha levels on rollover, but would prefer to change the tint instead. I understand I need to use a color transform, but am having a hard time seeing how to apply it.

    My current code, changing the alpha levels on rollover, is here:

    //Function for thumbnail rollovers
    mc.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);
    mc.addEventListener(MouseEvent.MOUSE_OUT, mouseOut);

    function mouseOver(event:MouseEvent):void {
    event.target.alpha = .7;
    }

    function mouseOut(event:MouseEvent):void {
    event.target.alpha = 1;
    }

    Does anyone know how I can change this code to apply
    a tint, let's say 50% of #000000, instead of changing
    the alpha levels?

  2. #2
    Senior Member
    Join Date
    Jan 2009
    Posts
    208
    why dont you use TweenLiteFilter?

  3. #3
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    you have to grab the object transform.colorTransform object. then you can make adjustments to either the offsets (-255 is darkest, 255 is brightest) or multipliers (decimal value). there are red, green, blue and alpha offsets, as well as multipliers. then you reassign that colortransform to the objects transform.colorTransform.

    here's basically what you want
    PHP Code:
    function mouseOver(event:MouseEvent):void {
        var 
    trans event.currentTarget.transform.colorTransform;
        
    trans.redOffset = -100;
        
    trans.blueOffset = -100;
        
    trans.greenOffset = -100;
        
    event.currentTarget.transform.colorTransform trans;
    }

    function 
    mouseOut(event:MouseEvent):void {
        var 
    trans event.currentTarget.transform.colorTransform;
        
    trans.redOffset 0;
        
    trans.blueOffset 0;
        
    trans.greenOffset 0;
        
    event.currentTarget.transform.colorTransform trans;


  4. #4
    Junior Member
    Join Date
    Nov 2007
    Posts
    27
    Thank you-that expained it in a way I could understand!

  5. #5
    ___________________
    Join Date
    May 2004
    Posts
    3,174

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