# One field two words

**URL:** <https://forum.kirupa.com/t/one-field-two-words/637897>\
**Category:** flash\
**Created:** [February 28, 2018, 8:23am UTC](https://forum.kirupa.com/t/one-field-two-words/637897 "2018-02-28T08:23:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![erezb1](https://avatars.discourse-cdn.com/v4/letter/e/ebca7d/32.png) [@erezb1](https://forum.kirupa.com/u/erezb1)\
**Post date:** [February 28, 2018, 8:23am UTC](https://forum.kirupa.com/t/one-field-two-words/637897/1 "2018-02-28T08:23:53Z")

</div>

Hi guys

wondered if i have one text field with two words, one needs to be bold and one regular.  
Is there an AS3 code which can achieve it ?

Thanks

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [February 28, 2018, 9:40pm UTC](https://forum.kirupa.com/t/one-field-two-words/637897/2 "2018-02-28T21:40:38Z")

</div>

Yes, the [setTextFormat](https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextField.html#setTextFormat()) method of TextField allows you supply the beginning and ending index of the text you want to change the format of.

---

<div class="post-metadata">

**Author:** ![erezb1](https://avatars.discourse-cdn.com/v4/letter/e/ebca7d/32.png) [@erezb1](https://forum.kirupa.com/u/erezb1)\
**Post date:** [March 1, 2018, 12:35pm UTC](https://forum.kirupa.com/t/one-field-two-words/637897/3 "2018-03-01T12:35:12Z")

</div>

Thanks TheCanadian

This is the script i used, Two text elements, one background which grows/shrinks according to both text fields and one mask for the business:

field1.harmonicTextField.text = “First”;  
field1.harmonicTextField.width = field1.harmonicTextField.textWidth+10  
field2.harmonicTextField.text = “Second”;  
field2.harmonicTextField.width = field2.harmonicTextField.textWidth+10  
field2.x = field1.x+field1.width+10;  
//box\_mc1.width = field1.harmonicTextField.width+field2.harmonicTextField.width+100;  
BG1.x = field1.harmonicTextField.textWidth+field2.harmonicTextField.textWidth-1360;  
mask1.x = field1.harmonicTextField.textWidth+field2.harmonicTextField.textWidth-1360;

Thanks again
