Skip navigation
Currently Being Moderated

colorChangeF(tf_mcHT_2.tf,0x000000);

May 6, 2012 7:46 AM

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

}

 
Replies
  • Currently Being Moderated
    May 6, 2012 8:00 AM   in reply to Ron Colmen

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    May 6, 2012 10:26 AM   in reply to Ron Colmen

    That should work Ron.

     
    |
    Mark as:
  • Currently Being Moderated
    May 6, 2012 3:04 PM   in reply to Ron Colmen

    You're welcome Ron

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points