Hi,
I have developed a flash app in AS3 that allows you to drag objects around on stage, save, and load them. When the “save” button is pressed, it then loops through each item on the stage and gets the coordinates (x and y) for the bottom left corner and the top right corner. Code:
ActionScript Code:
[LEFT][COLOR=#993300]var[/COLOR] bottomLeft:Point = [COLOR=#993300]new[/COLOR] Point[COLOR=#000000]([/COLOR]-[COLOR=#000000]50[/COLOR], -[COLOR=#000000]50[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#993300]var[/COLOR] topRight:Point = [COLOR=#993300]new[/COLOR] Point[COLOR=#000000]([/COLOR][COLOR=#000000]50[/COLOR], [COLOR=#000000]50[/COLOR][COLOR=#000000])[/COLOR];
bottomLeftX = mcsquare.[COLOR=#993300]localToGlobal[/COLOR][COLOR=#000000]([/COLOR]bottomLeft[COLOR=#000000])[/COLOR].[COLOR=#000000]x[/COLOR];
bottomLeftY = mcsquare.[COLOR=#993300]localToGlobal[/COLOR][COLOR=#000000]([/COLOR]bottomLeft[COLOR=#000000])[/COLOR].[COLOR=#000000]y[/COLOR];
topRightX = mcsquare.[COLOR=#993300]localToGlobal[/COLOR][COLOR=#000000]([/COLOR]topRight[COLOR=#000000])[/COLOR].[COLOR=#000000]x[/COLOR];
topRightY = mcsquare.[COLOR=#993300]localToGlobal[/COLOR][COLOR=#000000]([/COLOR]topRight[COLOR=#000000])[/COLOR].[COLOR=#000000]y[/COLOR];
[/LEFT]
It then takes this information and writes it to a database as an array.
When the “load” button is pressed, flash gets the array from the database, with the 4 x and y points.
I want to take these points an re-apply them to a new instance of the shape. Here is what happens.
NOTE: repondsXX[‘i][x]’ is the result from the database.
ActionScript Code:
[LEFT][COLOR=#f000f0]*// Make new instance*[/COLOR]
[COLOR=#993300]var[/COLOR] mcsquare = [COLOR=#993300]new[/COLOR] dragsquare[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#f000f0]*// Set points on new instance*[/COLOR]
[COLOR=#993300]var[/COLOR] bottomLeft:Point=[COLOR=#993300]new[/COLOR] Point[COLOR=#000000]([/COLOR]-[COLOR=#000000]50[/COLOR],-[COLOR=#000000]50[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#993300]var[/COLOR] topRight:Point=[COLOR=#993300]new[/COLOR] Point[COLOR=#000000]([/COLOR][COLOR=#000000]50[/COLOR],[COLOR=#000000]50[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#f000f0]*// Set the coordinates on the points*[/COLOR]
mcsquare.[COLOR=#993300]localToGlobal[/COLOR][COLOR=#000000]([/COLOR]bottomLeft[COLOR=#000000])[/COLOR].[COLOR=#000000]x[/COLOR] = respondsXX[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR][COLOR=#000000][[/COLOR][COLOR=#000000]3[/COLOR][COLOR=#000000]][/COLOR];
mcsquare.[COLOR=#993300]localToGlobal[/COLOR][COLOR=#000000]([/COLOR]bottomLeft[COLOR=#000000])[/COLOR].[COLOR=#000000]y[/COLOR] = respondsXX[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR][COLOR=#000000][[/COLOR][COLOR=#000000]4[/COLOR][COLOR=#000000]][/COLOR];
mcsquare.[COLOR=#993300]localToGlobal[/COLOR][COLOR=#000000]([/COLOR]topRight[COLOR=#000000])[/COLOR].[COLOR=#000000]x[/COLOR] = respondsXX[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR][COLOR=#000000][[/COLOR][COLOR=#000000]5[/COLOR][COLOR=#000000]][/COLOR];
mcsquare.[COLOR=#993300]localToGlobal[/COLOR][COLOR=#000000]([/COLOR]topRight[COLOR=#000000])[/COLOR].[COLOR=#000000]y[/COLOR] = respondsXX[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR][COLOR=#000000][[/COLOR][COLOR=#000000]6[/COLOR][COLOR=#000000]][/COLOR];
[COLOR=#f000f0]*// Add the square to the stage.*[/COLOR]
addChild[COLOR=#000000]([/COLOR]mcsquare[COLOR=#000000])[/COLOR];
[/LEFT]
However, the square being added is not taking the properites of the x and y coordinates I gave it.
So my question is: Is there a way of defining x and y coordinates for certain specific points on an object?
Thanks.