I am converting a room editor I had made in AJAX to Flash where users can move furniture around where they want, but I am running into some issues with the x,y coordinates. With the Javascript/AJAX setup, I recorded the X,Y coordinates of the furniture image, and it worked fine from the top left corner of the image. However, now trying to make it work, and load the same setups into Flash instead of with AJAX, the placement is all off. It appears that X,Y coordinates that are returned to me are from the center of the image instead of from the top left (if I drag something to the top left corner of a “room,” it shows X & Y as being half of the width and height).
Any reason why this would be? I as under the impression the X,Y coordinates worked the same in both Javascript and Flash.
I would assume that you are doing all of this with the Flash IDE, because had you loaded this all at runtime with purely code, you would have went out of your way to force these to center by specifying an x and y that is half it’s height and width. This all leads me to believe that you have put these into movieclips that you created with a centered registration.
You need to check the x,y of the bitmaps you are using as furniture. Make sure that they are at 0,0 inside their parent movieclips. Then you simply move the parent around. If your bitmaps have negative values of half their width and height as their x and y values, this would center your bitmap in the middle of the MovieClip/Sprite as opposed to having a top-left registration.
If you created a movieclip with centered registration, you do not have to destroy it a make a new one with another registration; Merely open the movieclip and set the bitmap/asset that is inside to a position of X: 0, Y: 0, then leave from inside the movieclip and once on the outside you will have to adjust it accordingly.