# Problem setting alpha to a Textfield

**URL:** <https://forum.kirupa.com/t/problem-setting-alpha-to-a-textfield/251838>\
**Category:** Uncategorized\
**Created:** [February 13, 2008, 3:21am UTC](https://forum.kirupa.com/t/problem-setting-alpha-to-a-textfield/251838 "2008-02-13T03:21:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![richierich1125](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@richierich1125](https://forum.kirupa.com/u/richierich1125)\
**Post date:** [February 13, 2008, 3:21am UTC](https://forum.kirupa.com/t/problem-setting-alpha-to-a-textfield/251838/1 "2008-02-13T03:21:17Z")

</div>

I want to dynamically pull text from a XML file and load it into a Textfield. I have added the text and applied styles to it via TextFormat. However, I can’t change the alpha to zero. I have no idea why. I even tried adding it into a sprite and setting the sprite’s alpha to zero. Can anyone help? Here is the code.

var txtName:TextField = new TextField;  
var myFormat:TextFormat = new TextFormat();  
var sprName:Sprite = new Sprite();  
sprName.addEventListener(Event.ADDED\_TO\_STAGE, AddComplete);

BuildFormat();  
BuildName();

function BuildFormat():void  
{  
myFormat.font = “Arial”;  
myFormat.color = 0x990000;  
myFormat.size = 22;  
}

function BuildName():void  
{  
txtName.autoSize = TextFieldAutoSize.LEFT;  
txtName.text = “This is a test.”;  
txtName.setTextFormat(myFormat);  
sprName.addChild(txtName);  
addChild(sprName);  
}

function AddComplete(event:Event):void  
{  
sprName.x = stage.stageWidth - sprName.width;  
sprName.y = stage.stageHeight - sprName.height;  
sprName.alpha = 0;  
}
