Another problem… Trying to add event listeners to check whether my tiles are being pressed! This works excellent! They respond to the listeners BUT on the mose_down/mouse_up i canät trace the tile variables!!!
The listener functions:
function over(evt:MouseEvent):void {
evt.target.alpha=.75;
coordTxt.text="X: "+evt.target.myX+" Y: "+evt.target.myY;
}
function out(evt:MouseEvent):void {
evt.target.alpha=1;
[COLOR=Red] trace(evt.target.myX);[/COLOR]//RETURNS CORRECT VALUE
coordTxt.text="X: - Y: -";
}
function ner(evt:MouseEvent):void {
[COLOR=Red] trace(evt.target.myX);[/COLOR]//RETURNS UNDEFINED
if (evt.target.myX==0) {
trace("dragging");
} else {
trace("not dragging");
evt.target.alpha=0.5;
}
}
function upp(evt:MouseEvent):void {
trace("släppt!")
}
This is where I’ve added the listeners:
patch.name="tile"+k;
patch.x=-25-finito*25+50*i;
patch.y=-25-finito*25+50*j;
patch.myX = (X-(finito/2))+i;
patch.myY = ((finito/2)+Y)-j;
patch.myType=xy;
patch.addEventListener(MouseEvent.ROLL_OVER, MovieClip(root).over);
patch.addEventListener(MouseEvent.ROLL_OUT, MovieClip(root).out);
patch.addEventListener(MouseEvent.MOUSE_DOWN, MovieClip(root).ner);
patch.addEventListener(MouseEvent.MOUSE_UP, MovieClip(root).upp);
addChild(patch);