Copy link to clipboard
Copied
Hi. I have dynamic textboxes which is included in the movieclip button. I set the text like this : " buttona.label_txt.text" . However when the button was hit, the color of the button changed based on what I've set but the text is missing. I already check the properties of the textbox and already make sure the color was black, as it was supposed to be. But it still missing.
Here is the code:
var _list:Array = ["XXXquestionsXXX"];
var _marks:Array = [];
var i:int;
var myscore = 0;
question_txt.text = _list[0];
buttonA.label_txt.text = "A. Chicken";
buttonA.addEventListener(MouseEvent.CLICK, q1);
function q1(event:MouseEvent):void
{
if(event.currentTarget == buttonA)
{
_marks.push("Jawapan anda : A. chicken /" + "Correct");
var SelColor1:Number = 0XFFFF0;
var myColorTransform1 = new ColorTransform();
myColorTransform1.color = SelColor1;
buttonA.transform.colorTransform = myColorTransform1;
}
Copy link to clipboard
Copied
assigning the colortransform of buttonA changes the buttonA and all its children. so your text color is the same as the buttonA color. ie, the text is there but you can't see it. (if you make it selectable and mouseChildren is enabled, you should be able to select it and see it.)
to remedy, assign the buttonA background to be a movieclip (which will be a child of buttonA). use your colortransform on that background.
Copy link to clipboard
Copied
I changed the coding to buttonA.getChildat(0).transform.colorTransform = myColorTransform;
but I get an error, Error #1006 : getChildat is not a function.. why is it happening ? First hit on the button, the border of the button changed to other color. But, I tried to hit for second time, the error appeared.
Copy link to clipboard
Copied
you have a typo. getChildAt != getChildat
that's poor coding in any case. assign the child a reference that you can use in your code.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now