-
1. Re: Help With Button Coding
kglad Apr 5, 2012 8:47 AM (in response to ilovetoread247)what is it that, you think, doesn't work with buttons?
-
2. Re: Help With Button Coding
ilovetoread247 Apr 5, 2012 11:27 AM (in response to kglad)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.
-
3. Re: Help With Button Coding
kglad Apr 5, 2012 5:33 PM (in response to ilovetoread247)you should remove all code from objects. so, whatever button has that code attached should be given an instance name (eg, btn) so you can use:
btn.onRelease = function(){
for(var i:String in _root){
if(i.indexOf("shirt") > -1){
_root[i].gotoAndStop(2);
}
}
};
}