I have a movie clip that has a text field and then a button inside that. I need to be able to change the color of the text when user mouse hovers over the text. Below is the code snippet. How do I access a reference to the Text field from outside the function? Thanks in advance.
private function createRows() { var containerMc:MovieClip = row;
//Create Text
var myTxt:TextField = new TextField();
myTxt.htmlText = labelName;
myTxt.antiAliasType = AntiAliasType.ADVANCED;
myTxt.selectable = false;
//Create Symbol Format Text
var myTxtFormat:TextFormat = new TextFormat();
myTxtFormat.color = 0x000000;
myTxtFormat.font = font;
myTxtFormat.bold = "bold";
myTxtFormat.size = fontSize;
//Format text
myTxt.setTextFormat(myTxtFormat);
containerMc.addChild(myTxt);
//Create button
var btn:Sprite = new Sprite();
btn.graphics.beginFill(rowColor);
btn.graphics.drawRect(0, 0, width, height);
btn.graphics.endFill();
btn.alpha = 0;
btn.name = someName;
btn.buttonMode = true;
btn.addEventListener(MouseEvent.MOUSE_OVER,testMouseOver);
containerMc.addChild(btn);
}
private function testMouseOver(e:MouseEvent) { var myTxtFormat:TextFormat = new TextFormat(); myTxtFormat.color = 0xccff00;
var myText:TextField = new TextField;
myText.htmlText = e.currentTarget.name;
myText.setTextFormat(symTxtFormat);
}