# Changing colour with actionscript?

**URL:** <https://forum.kirupa.com/t/changing-colour-with-actionscript/258493>\
**Category:** flash\
**Created:** [April 24, 2008, 3:18pm UTC](https://forum.kirupa.com/t/changing-colour-with-actionscript/258493 "2008-04-24T15:18:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tommiwalsh](https://avatars.discourse-cdn.com/v4/letter/t/dc4da7/32.png) [@tommiwalsh](https://forum.kirupa.com/u/tommiwalsh)\
**Post date:** [April 24, 2008, 3:18pm UTC](https://forum.kirupa.com/t/changing-colour-with-actionscript/258493/1 "2008-04-24T15:18:50Z")

</div>

Hi,

I have a menu made with AS 2.0 that gets its values from an xml file, its a collapsable menu and I want the secondary nav (or sub nav) not only to indent but to be a different colour?

Heres the code I’m trying to alter-

```auto
TextFieldClass.prototype.drawText = function(newName, x, y, w, h) {
    // ---set unique depth to attach at
    ++this.depth;
    // ---basic MX create blank textfield method
    this.tempText = this.createTextField(newName, this.depth, x, y, w, h);
    // ---link between new textfield and parent Object
    this.tempText.parent = this;
    // ---set textfield type: "dynamic" or "static" or "input"
    this.tempText.type = this.fieldType ? this.fieldType : "dynamic";
    // ---allow cursor selection of text
    this.tempText.selectable = false;
    // ---specify HTML text 
    this.tempText.htmlText = this.title;
    // ---control textfield background colour
    if (this.applyBground) {
        this.tempText.background = false;
        // ---background colour matches button background colour
        this.tempText.backgroundColor = parseInt(this.blurColour);
        // ---would only apply if textfield was "input" type and selectable
        if (this.applyFocus) {
            this.tempText.onSetFocus = this.handleFieldFocus;
            this.tempText.onKillFocus = this.handleFieldBlur;
        }
    }
    // ---embed fonts for antialiasing
    // this.tempText.embedFonts = true;
    // ---specify password type textfield 
    this.tempText.embedFonts = true;
    if (this.protect) {
        this.tempText.password = true;
    }
    // ---define appearance of textfield content
    this.styleObj = new TextFormat();
    this.styleObj.font = "Helvetica Neue";
    this.styleObj.size = 12;
    this.styleObj.bold = true;
    this.styleObj.leading = -30;
    // if this is a secondary button, indent by 5 pixels
    this.styleObj.indent = this.applyindent ? 15 : 5;
    // ---apply style to textfield
    this.tempText.setTextFormat(this.styleObj);
};
// ---[method] changes textfield background colour on focus
TextFieldClass.prototype.handleFieldFocus = function() {
    this.backgroundColor = this.parent.focusColour;
};
// ---[method] changes textfield background colour on blur
TextFieldClass.prototype.handleFieldBlur = function() {
    this.backgroundColor = this.parent.blurColour;
};
// ---test whether textfield contains text, returns a boolean
TextFieldClass.prototype.isEmpty = function() {
    if (this.txt.text == "") {
        return (true);
        break;
    }
    return (false);
};

```

It says that he uses this code to indent the sub nav-

```auto
// if this is a secondary button, indent by 5 pixels
    this.styleObj.indent = this.applyindent ? 15 : 5;

```

so I’ve tried similar things to that but with colour specifications instead but still no luck, any ideas? Its probably pretty simple but I can’t seem to get it to work?
