So apparently I encountered a problem where when I call a constructor and set the object's property in it, the output is not correct.
I have class named Patch. I tried to call this constructor:
public function Patch()
{
this.addEventListener (Event.ADDED_TO_STAGE, addedToStageHandler);
}
private function addedToStageHandler(evt:Event)
{
_stageW = stage.stageWidth;
_cropArray = new Array();
this.x = 55;
this.y = 76;
_stageW = 800; //FIXME: Coded hard
_transition = new Tween (this, "x", Regular.easeInOut, 0, 0, 1, true);
_transition.stop();
}
As you can see, there's this
this.x = 55;
this.y = 76;
line. Obviously, I want to set its position to x:55 and y:76. However, whenever I call the constructor, the object x's position always be at 0. Surprisingly, when I try to set the object's property outside the constructor, the object's x coordinate still at 0
var p:Patch = new Patch();
p.x = 55;
p.y = 76;
addChild (p);
At this point I decided to comment the
this.x = 55;
this.y = 76;
line in the class AS file and once again create an instance of Patch class. Still to no avail. I used other value than 55 (e.g. 334, 90) to check if that matters. Still misplaced at x:0.
For your information, Y coordinate acts just well. Played with it a bit, and it's just fine.
I want to know what is the main problem. Is it the class? Is it any other things? I'd gladly receive any answer (except bashing one) or any reference link. If necessary I can include the rest of the source code. Thank you in advance!
