Hello all,
I am having an interesting problem on a flash game that I am trying to create. Basically, I am trying to create multiple copies of the same MC and allow users to position them in various places around the stage. Thus, I am trying to use an associative array to do this. Here is my code:
on the root:
var itemList:Object = new Object();
on the button to create the duplicate clip:
on (press) {
b++;
//Deskdragmovie.duplicateMovieClip("Deskdragmovie" + b, this.getNextHighestDepth(), {_x:400, _y:150});
//var mc2:MovieClip = eval("Deskdragmovie" + b);
var mc2:MovieClip = Deskdragmovie.duplicateMovieClip("Deskdragmovie" + b, this.getNextHighestDepth(), {_x:400, _y:150});
var objdesk:Object = new Object();
objdesk._name = mc2._name;
objdesk._x = mc2._x;
objdesk._y = mc2._y;
objdesk._rotation = mc2._rotation;
objdesk.depth = mc2.getDepth();
this._root.itemList[objdesk._name] = objdesk;
}
Finally - here is the code to trace the results:
on(press) {
for( var prop in _root.itemList){
trace(_root.itemList[prop]._name);
trace(_root.itemList[prop]._x);
trace(_root.itemList[prop]._y);
trace(_root.itemList[prop]._rotation);
trace(_root.itemList[prop].depth);
}
}
The problem is that on the trace, the _x, and _y are traced as _x:400, _y:150, just as the x/y that I set the duplicated clip to, even though it has been dragged to a different position. Also, the rotation is not working, although the name and depth are working fine.
I eventually want to store these positions in a database so that the user can return and see the room they designed with the MCs at a later date.
Thank you all so very much for your time and help!!!