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