Flex Sprite xy Coordinates
Posted
by Ian
on Stack Overflow
See other posts from Stack Overflow
or by Ian
Published on 2010-06-02T11:13:30Z
Indexed on
2010/06/02
11:13 UTC
Read the original article
Hit count: 184
flex
Hi,
I have a drawing that looks more or less like the attached image. image
The orange square is the currently selected selected sprite.
The sprites are all draws from coordinates that i receive from XML.
var sprObject:Sprite = new Sprite();
sprObject.graphics.beginFill(itemList.c.toString());
sprObject.name = strName;
sprObject.graphics.moveTo(iX, iY);
sprObject.graphics.lineTo(iX2, iY2);
sprObject.graphics.lineTo(iX3, iY3);
sprObject.graphics.lineTo(iX4, iY4);
sprObject.graphics.lineTo(iX, iX);
sprObject.graphics.endFill();
mainUI.addChild(sprObject); // mainUI is a mx:UIComponent
g_Sprite.push(sprObject); // array of sprites.
What I want to do is the following. If I'm currently on the orange square and I use my keyboard direction buttons (up/down/left/right). I want to deselect the current sprite and select the next sprite in the appropriate direction.
The problem I'm having is that I cannot get the x and y coordinates of the drawn sprites. If I look in the array, the x and y coordinates of the sprites are all 0. If I can retrieve that I can write an algorithm to determine the next sprite to select.
Any help would be appreciated.
© Stack Overflow or respective owner