Skip to main content
Participating Frequently
August 30, 2013
Answered

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

  • August 30, 2013
  • 3 replies
  • 1023 views

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);

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer kglad

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..

3 replies

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
August 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..

maulshreAuthor
Participating Frequently
August 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

kglad
Community Expert
Community Expert
August 30, 2013

you're welcome.