Changing the color of a piece of text onRollOver


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // Most of the time when you have a checkbox with a label and link in that label, you just want to change the color of that link on rollOver or rollOut. Here is how:
  2. // In your button class
  3.  
  4. private function overState():void {
  5. var correctIndex:int = _label.text.toLowerCase( ).indexOf( "text i want to change color to" );
  6.  
  7. var tF:TextFormat = Fonts.getFormat( Fonts.AVANTGARDE );
  8. tF.color = 0xFFCC00;
  9. _label.setTextFormat( tF , correctIndex , _label.text.length );
  10. }
  11.  
  12. private function outState():void {
  13. var tF:TextFormat = Fonts.getFormat( Fonts.AVANTGARDE );
  14. tF.color = 0xCCFF00;
  15. _label.setTextFormat( tF );
  16. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.