Reputation: 101
How can I make this work? I need to remove the word Button from the reference to reference the actual item that will be tinted. Thank you in advance.
disagreeButton.addEventListener(MouseEvent.ROLL_OVER, mouseRollOver);
contentMain.clickButton1.addEventListener(MouseEvent.ROLL_OVER, mouseRollOver);
function mouseRollOver(e:MouseEvent):void {
var c:Color = new Color();
c.setTint (0xFFFFFF, 1);
//the issue is this line:
this[e.target.name.replace( "Button", "" )].transform.colorTransform = c;
}
Upvotes: 1
Views: 203
Reputation: 10325
Now that I understand your problem, I would recommend the following.
Have separate methods for buttons in this
, and in contentMain
, and any others. Then access the objects by this[...]
or contentMain[...]
, where appropriate.
disagreeButton.addEventListener(MouseEvent.ROLL_OVER, mainMouseRollOver);
contentMain.clickButton1.addEventListener(MouseEvent.ROLL_OVER, contentMainMouseRollOver);
function mainMouseRollOver(e:MouseEvent):void {
mouseRolloverLogic(this[e.target.name.replace( "Button", "" )];
}
function contentMainMouseRollOver(e:MouseEvent):void {
mouseRolloverLogic(contentMain[e.target.name.replace( "Button", "" )];
}
function mouseRolloverLogic(item:DisplayObject):void {
var c:Color = new Color();
c.setTint (0xFFFFFF, 1);
item.transform.colorTransform = c;
}
Add extra logic to the method you have.
if (this[...] != null) {
...
}else if (contentMain[...] != null) {
...
}
Upvotes: 1