Skip to main content
Inspiring
May 6, 2012
Answered

colorChangeF(tf_mcHT_2.tf,0x000000);

  • May 6, 2012
  • 1 reply
  • 1016 views

I want to change the color of a text. Below is my code. Everything works except for colorChangeF(textNumNowCol,0x000000);

It works when I try replacing

colorChangeF(textNumNowCol,0x000000);

with

colorChangeF(tf_mcHT_1.tf,0x000000); or colorChangeF(tf_mcHT_2.tf,0x000000); or colorChangeF(tf_mcHT_3.tf,0x000000); ....

/////first part of the code:

var textNum:Number = 1;

var tf_mcHT:MovieClip = tl.attachMovie("tfID"+typeNow_tx.text,"tf_mcHT_"+textNum++,tl.getNextHighestDepth());

textNumNow = textNum -1;

////second part of the code:

textNumNowCol = "tf_mcHT_"+textNumNow+".tf";

trace (textNumNowCol) // shows correctly as tf_mcHT_1.tf or tf_mcHT_2.tf or tf_mcHT_3.tf...

colorChangeF(textNumNowCol,0x000000);

{   _root.CN5.text= _root.CN55.text="BLACK"}

{   _root.defTC.text="0x000000"}

}

function colorChangeF(mc:MovieClip, col:Number):Void {

    mc.c = new Color(mc);

    mc.c.setRGB(col);

}

This topic has been closed for replies.
Correct answer Ned Murphy

textNumNowCol = "tf_mcHT_"+textNumNow+".tf";

is assigning a String to the textNumNowCol variable, not an object. 

I am pretty sure you've been shown how to use bracket/array notation to be able to target an object using a string representation of its instance name.  See if you can remember and apply it to what you tried to do in that line.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
May 6, 2012

textNumNowCol = "tf_mcHT_"+textNumNow+".tf";

is assigning a String to the textNumNowCol variable, not an object. 

I am pretty sure you've been shown how to use bracket/array notation to be able to target an object using a string representation of its instance name.  See if you can remember and apply it to what you tried to do in that line.

Inspiring
May 6, 2012

Thanks Ned! done

Is this what's expected?

textNumNowCol = "tf_mcHT_"+String(textNumNow);

colorChangeF(this[textNumNowCol].tf,0x000000);

Ned Murphy
Legend
May 6, 2012

That should work Ron.