# AS3, how to set random color for text field?

**URL:** <https://forum.kirupa.com/t/as3-how-to-set-random-color-for-text-field/233541>\
**Category:** flash\
**Created:** [July 24, 2007, 8:15pm UTC](https://forum.kirupa.com/t/as3-how-to-set-random-color-for-text-field/233541 "2007-07-24T20:15:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![albisher](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@albisher](https://forum.kirupa.com/u/albisher)\
**Post date:** [July 24, 2007, 8:15pm UTC](https://forum.kirupa.com/t/as3-how-to-set-random-color-for-text-field/233541/1 "2007-07-24T20:15:00Z")

</div>

hi kirupa friends 🙂

if i have a simple text field like:

```auto

var myText1:TextField = new TextField();
myText1.text = "my text is written here";
myText1.autoSize = TextFieldAutoSize.LEFT;
addChild(myText1);

```

how can i set a random color for that field?  
i found in help files something like:

```auto

function getRandomColor():ColorTransform
{
    return new ColorTransform(Math.random(), Math.random(), Math.random(),1,(Math.random() * 512) - 255, (Math.random() * 512) -255, (Math.random() * 512) - 255, 0);
}

```

how do i use it?
