0 Replies Latest reply on Dec 15, 2009 1:07 PM by flairjax

    TextBlock, TextElement changing color dynamically

    flairjax Level 1

      So I decided try out the TextBlock and TextElement in my project, but I can't seem to change the color dynamically.  Here is the code:

       

      //show the name of the node in a textSprite label
              private function addNameLabel():void
              {
                  trace('addNamelabel called');
                  textSpriteHolder = new Sprite;
                  var scAmt:Number = Math.round(11 * _scaleFactor);
                  var temp:String = _nodedata.name;
                 
                  var whitespace:RegExp = /(\-)/g;
                  temp = temp.replace( whitespace, '_' ); 
                  txt = truncateTextField( temp as String );
                 
                  var fd:FontDescription = new FontDescription();
                  fd.fontLookup = FontLookup.EMBEDDED_CFF;
                  fd.fontName = "Arial, Helvetica, _sans";
                  var ef:ElementFormat = new ElementFormat(fd);
                  ef.fontSize = 22;
                  ef.color = 0x000000;
                  te = new TextElement(txt, ef);
                  tb = new TextBlock();
                  tb.content = te;
                 
                  textsprite = tb.createTextLine(null, 300);
                  var baremin:Number = Math.max( graphNode.width, 73 );
                  textsprite.x    = ( baremin / 2) + 10;
                  textsprite.y    = -5;
                  textsprite.name = "label";
                  textsprite.mouseEnabled = false;
                  textsprite.mouseChildren = false;
                  textsprite.alpha = 1;
                  textSpriteHolder.addChild(textsprite);
                  graphNode.addChild(textSpriteHolder);
                 
              }

       

       

      Anyone know how to change the color of the text, later on say when a threshold is met (aka not during instantiation).