PDA

View Full Version : [FMX]What is wrong with my code



dboers
November 8th, 2004, 07:59 AM
Hi I have a few buttons on the stage and a simalar quantity of mc's with the same suffix as the buttons I would like to change the color of the movieclips at rollOver and restore the color again at rollOut. To do so I came up with the following function:

function buttons() {
for (var i in this) {
if (this[i]._name.substr(0, 4) == "btn_") {
clip = this[i];
clip.myOver = _root["rollOver_"+clip._name.substr(4, clip._name.length)];
clip.onRollOver = function() {
this.myOver.setRGB(0xD86C01);
};
clip.onRollOut = function() {
new Color(myOver).setRGB(0xCC6600);
};
}
}
}
buttons();


But that isn't working. What am I doing wrong?

Thanks in advance

eki
November 8th, 2004, 08:17 AM
function buttons() {
for (var i in this) {
if (this[i]._name.substr(0, 4) == "btn_") {
clip = this[i];
//clip.myOver = _root["rollOver_"+clip._name.substr(4, clip._name.length)];
clip.clipColor = new Color(clip);
clip.clipColor.setRGB(0xD86C01);
clip.onRollOver = function() {
trace("this: "+(this));
this.clipColor.setRGB(0xD86C01);
};
clip.onRollOut = function() {
this.clipColor.setRGB(0xCC6600);
};
}
}
}
buttons();

dboers
November 8th, 2004, 09:30 AM
Thank you for the reply. In your example the color of the buttons are changing but instead the color of the other movie clips should change. I will try to be more clear.


I have four buttons (btn_home, btn_service, btn_product, btn_contact) next to those buttons I have 4 movieclips (rollOver_home, rollOver_service, rollOver_product and btn_contct) When I roll over btn_home the color of rollOver_home should change etc. That's where the clip.myOver = _root["rollOver_"+clip._name.substr(4, clip._name.length)]; is for to let them interact with eachother. I hope this is a little clearer

Thanks in advance

eki
November 8th, 2004, 10:01 AM
Hi,
you're welcome

is this what you mean?



function buttons() {
for (var i in this) {
if (this[i]._name.substr(0, 4) == "btn_") {
clip = this[i];
clip.myOver = _root["rollOver_"+clip._name.substr(4, clip._name.length)];
clip.clipColor = new Color(clip.myOver);
clip.clipColor.setRGB(0xCC6600);
clip.onRollOver = function() {
trace("this: "+(this));
this.clipColor.setRGB(0xD86C01);
};
clip.onRollOut = function() {
this.clipColor.setRGB(0xCC6600);
};
}
}
}

buttons();



SHO

dboers
November 8th, 2004, 10:11 AM
That I didn't see that myself..... Kind of stuppid


That's working great eki, thanks a lot :)

eki
November 8th, 2004, 10:13 AM
Any time :)