Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to set properties for dynamic text ?

Guest
Apr 02, 2016 Apr 02, 2016

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;

  }

TOPICS
ActionScript
363
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 02, 2016 Apr 02, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 02, 2016 Apr 02, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 03, 2016 Apr 03, 2016
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines