1
votes

I have a strange problem. I have a two sprites that are added to other Sprite and I, with localToGlobal(), get their global x,y coordinates, but when I add another movieclip and try to move them to "global" coordinates on ENTER_FRAME event, they are locked on 0,0 of the stage??

I have traced coords and they are correct but no positioning... Why?

var point:Point = new Point();
addChild(pl_name);
pl_name.addEventListener(Event.ENTER_FRAME, mov);
function mov(e:Event):void
{
for (var i in players)
{

    var gglobal:Point = players[i].localToGlobal(point);
    pl_name.x = gglobal.x;
    pl_name.y = gglobal.y;
    trace ("nameX "+pl_name.x+"    nameY "+pl_name.y);
}

}

1
Can we have some code, please. - strah
A little bit more code, please. It doesn't show the problem. - strah
That's it, i don't see it ether :) - Marko Mladenovic
You have 1 Sprite and inside there are 2 other sprites + the movieclip. And you will position the movieclip inside the sprite to the global coordinates? - WolvDev

1 Answers

0
votes

The point you are giving it isnt set to anything before it is used. Try this.

point.x = players[i].x; point.y = players[i].y; var gglobal:Point = players[i].localToGlobal(point);