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

how to change backgroundColor of TextInput which is inside a movieclip in AS3?

Community Beginner ,
Aug 30, 2013 Aug 30, 2013

Hi,

I've created a movieclip instance named grid1 and is accessing various child objects (textInputs)  inside that movie clip using - grid1.getChildAt(1).scaleX=10; (eg).

However, what's wrong with the below lines?

grid1.getChildAt(1).textField.backgroundColor=0xffcc00;

Error 1119: Access of possibly undefined property textField through a reference with static type : flash.display:DisplayObject;

or

grid1.getChildAt(1).setSize(500,500);

Error:1061: Call to a possibly undefined method setSize through  a reference with static type: flash.display:DisplayObject;

when textInput 'text1' is on stage, following codes are working fine:

text1.textField.backgroundColor = 0xffcc00;

text1.setSize(120,50);

TOPICS
ActionScript
976
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

correct answers 1 Correct answer

Community Expert , Aug 30, 2013 Aug 30, 2013

if you have a correct reference, cast that object as a TextInput.  but, in general, that's poor coding.

assign your textinput an instance name (eg, ti) and use that in your reference:

var ti:TextInput=TextInput(grid1.getChildByName("ti"));

ti.background=true;

ti.etc..

Translate
Community Expert ,
Aug 30, 2013 Aug 30, 2013

if you have a correct reference, cast that object as a TextInput.  but, in general, that's poor coding.

assign your textinput an instance name (eg, ti) and use that in your reference:

var ti:TextInput=TextInput(grid1.getChildByName("ti"));

ti.background=true;

ti.etc..

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 Beginner ,
Aug 30, 2013 Aug 30, 2013

thank  a tonne for the guidance... following worked for me-

var ti:TextInput=TextInput(grid1.getChildByName("text1"));

ti.textField.background=true;

ti.textField.backgroundColor=0xffcc00;

//where text1 is my TextInput reference inside MovieClip grid1

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 ,
Aug 30, 2013 Aug 30, 2013
LATEST

you're welcome.

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