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.getNext HighestDepth());
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);
}
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.
North America
Europe, Middle East and Africa
Asia Pacific