I make dress up games in ActionScript 2, and am having a problem.
I want to make a button find all movieclip items with, say, "shirt" in their Instance Name, and move them to frame 2. I know how to do this with one item, (on(release){
_root.shirt1.gotoAndStop(1);
}
and on previous games, I merely copied and pasted that several dozen times for every item. However, on this game, I am trying to cut down on code, and learned how to use
for(var i:String in _root){
if(i.indexOf("_drag") > -1){
_root[i].onPress = function(){
(put in the code)
(put in the closing }s)
on the stage to make items drag and snap into place. I have learned that this code cannot be used on buttons, which need static commands, I think? I'm still very much a novice.
Any help would be appreciated!
I discovered my mistake- kind of (I had forgotten to indent). However, I now have two related problems.
One: the code I am using is
on(release){
for(var i:String in _root){
if(i.indexOf("shirt") > -1){
_root[i].onPress = function(){
this.gotoAndStop(2);
}
}
};
}
the onPress here refers to the item- I have to press the button, then the item, for it to move to the next frame. I don't like this, and want the button to do all the work for me. How do I do this?
Secondly, this overrides the original code on a frame of the stage, given above, and the items no longer drag. This is obviously not what I want. How do I make sure the items are "hearing" both codes?
Thank you, and sorry.
North America
Europe, Middle East and Africa
Asia Pacific