# Object data member not changing when assigned value

**URL:** <https://forum.kirupa.com/t/object-data-member-not-changing-when-assigned-value/232915>\
**Category:** flash\
**Created:** [July 18, 2007, 6:29pm UTC](https://forum.kirupa.com/t/object-data-member-not-changing-when-assigned-value/232915 "2007-07-18T18:29:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![icekube12jr](https://avatars.discourse-cdn.com/v4/letter/i/c89c15/32.png) [@icekube12jr](https://forum.kirupa.com/u/icekube12jr)\
**Post date:** [July 18, 2007, 6:29pm UTC](https://forum.kirupa.com/t/object-data-member-not-changing-when-assigned-value/232915/1 "2007-07-18T18:29:23Z")

</div>

Hi,

So I’ve run into a problem with assigning a value to some of my object’s data members.  
Here’s what’s going on:

I have a class called Tile. Here is the code for the class (just the part that you need to see):

public class Tile extends MovieClip {

```
private var testVar:String;

public function Tile() {
    testVar = "initialized testVar";
    this.addEventListener(MouseEvent.CLICK, mouseClickHandler);
}

private function mouseClickHandler(event:MouseEvent):void {
    trace(testVar);
}

public function setTest(s:String):void {
    testVar = s;
}

```

}

Out side of this class I make two simple calls. One to initialize the object and the other to call the function (the object is already present on the stage btw so I CAN click it). The call is:

var myObject:Tile = new Tile();  
myObject.setTest(“cool”);

Now when I run the program and I click on myObject, it spits out:

initialized testVar

click it again… and again… and again lol. Same thing over and over. So I thought maybe my call outside the class was somehow incorrect. I made a trace within the setTest function so that it looked like this:

public function setTest(s:String):void {  
testVar = s;  
trace (testVar);  
}

This time it spits out:

cool

Then when I click it always gives me:

initialized testVar

Why won’t my data member change?

icekube12jr
