Change color of a dynamic textfield problem
-
22-08-2019 - |
Question
I have this code that should change the color of a dynamic textfield when I rollover the link movieclip, and then back when I rollout. I get no compiler error, it just doesn't work.
function textColor(mc_function:MovieClip, tf_text:TextField) {
mc_function.onRollOver = function() {
tf_text.textColor = 0x7cb0b7;
};
mc_function.onRollOut = function() {
tf_text.textColor = 0xffffff;
};
}
boxLink(link_a1,text_a1);
boxLink(link_a2,text_a2);
boxLink(link_a3,text_a3);
Any thoughts?
Solution
Try this:
function SetMouseAction(pMovieClip, pTextField):Void {
pMovieClip.linkedText = pTextField;
pMovieClip.onRollOver = function() {
this.linkedText.textColor = 0x7cb0b7;
};
pMovieClip.onRollOut = function() {
this.linkedText.textColor = 0xffffff;
};
}
SetMouseAction(link_a1, text_a1);
SetMouseAction(link_a2, text_a2);
SetMouseAction(link_a3, text_a3);
at least I have tested it and it works for me
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow