Hi,
I have some code that adds a child using addChild(dragsquare); dragsquare is what I used as the class for a movieclip, mcsquare.
Everytime a child is added to the stage, it is called: ObjectX
The “X” increments everytime a new object is added using ++objNum.
E.g:
Object1
Object2
Object3
etc…
When the child is added to the stage, it can be dragged, resized, rotated, etc…
I have used this code so when someone clicks the “save” button it loops through all objects on stage (increasing the last number by 1 to get the next object) and finding their properties. Here is the code I have used.
ActionScript Code:
[LEFT]save.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000000]MOUSE_UP[/COLOR], saveObjects[COLOR=#000000])[/COLOR];
[COLOR=#993300]function[/COLOR] saveObjects[COLOR=#000000]([/COLOR]event:MouseEvent[COLOR=#000000])[/COLOR]:[COLOR=#993300]void[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]for[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#993300]var[/COLOR] i:uint=[COLOR=#000000]0[/COLOR]; i<numChildren-[COLOR=#000000]23[/COLOR]; i++[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]var[/COLOR] objName:[COLOR=#993300]String[/COLOR]=[COLOR=#0000ff]"Object"[/COLOR]+i;
[COLOR=#993300]var[/COLOR] mc = getChildByName[COLOR=#000000]([/COLOR]objName[COLOR=#000000])[/COLOR];
[COLOR=#993300]trace[/COLOR][COLOR=#000000]([/COLOR]mc.[COLOR=#000000]scaleX[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#993300]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]"object "[/COLOR]+i+[COLOR=#0000ff]" saved"[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[/LEFT]
23 children already exist on stage so I have to minus that number to get whatever is added on stage by the user.
However, scaleX is getting the childs ORIGINAL properties and not its current stage properties (where it has been resized, rotated etc…) and only returns a 1 for scaleX. How would I make it track the properties it has on stage?
Thanks.