Skip to main content
HSS Sursee
Known Participant
July 14, 2023
Question

Movieclip change Color

  • July 14, 2023
  • 2 replies
  • 181 views

I made a rectangle to a movieclip and want to change the color on a mouseover. I can change the color of the textfield but with my background rectangle it's not working (not working code is bold and italic).

 

This is my code for now:

var _this = this;
stage.enableMouseOver(3);
_this.Start_Level_1.on('mouseover', function(){

_this.Start_Level_1.Start_Level_1_Grafik.color = 'blue';

_this.Start_Level_1.Start_Level_1_Text.color = 'black';
});

 

Thanks for your help.

    This topic has been closed for replies.

    2 replies

    kglad
    Community Expert
    Community Expert
    July 14, 2023

    you should really convert the rectangle to an symobl (eg, movieclip), assign it an instance name and then assign its children[0].graphics._fill.style.

    JoãoCésar17023019
    Community Expert
    Community Expert
    July 14, 2023

    Hi.

     

    If your MovieClip instance only contains a text field and a raw vector shape and if you're are using Animate's default publish settings, then you could use the _fill property like this:

    var _this = this;
    
    stage.enableMouseOver(3);
    
    _this.Start_Level_1.on('mouseover', function(e)
    {
    	e.currentTarget.yourTextField.color = 'blue';
    	e.currentTarget.children[0].graphics._fill.style = 'black';
    });

     

    I hope this helps.

     

    Regards,

    JC