# Class Communication

**URL:** https://forum.kirupa.com/t/class-communication/327287
**Category:** flash
**Created:** [February 19, 2012, 2:14pm UTC](https://forum.kirupa.com/t/class-communication/327287 "2012-02-19T14:14:34Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jeponkz](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@jeponkz](https://forum.kirupa.com/u/jeponkz)
#### Post date: [February 19, 2012, 2:14pm UTC](https://forum.kirupa.com/t/class-communication/327287/1 "2012-02-19T14:14:34Z")

</div>

I have the following scenarios.

Main Class:

btnChangeText.addEventListener (MouseEvent.CLICK, onClick)

function onClick(e:MouseEvent)  
{  
var content:Content = new Content()  
content.contentTxt= “Hello World”  
content.initialize();  
addChild(content);  
}

Content Class:

public class Content extends Sprite  
{  
public var contentTxt:String;

public function Content()  
{  
txtField.text = “Lorem Ipsum” //this is the default text…  
}

public function initialize()  
{  
txtField.text = contentTxt;  
// lets assumed that we have already the textfield name txtField  
}

}

now the question is that, how can I change the txtField.text without using the addChild function in the main class?? because the Content Class is already visible when you compile it… and when I remove the that addChild function, the txtField.text is still in its default value which is “Lorem Ipsum”
