all groups > flash actionscript > january 2006 >
You're in the

flash actionscript

group:

button movie


button movie dirkness
1/21/2006 8:35:55 PM
flash actionscript:
Hi

I've implemented the script below to control some button movies - and it works
fine.

But I'd like the script to instruct the button to stay down once clicked - and
then for it to revert to the up state (frame 1) when another button is clicked.

So the current page is always indicated by a down state (frame 4).

Any ideas on how the script can be adjusted to achieve this?

Thanx

Dirk


total = 7;//
this.onEnterFrame = function() {
for (var i = 1; i<=total; i++) {
if (this["button"+i]._currentframe != 7) {
if (this["button"+i].hitTest(_xmouse, _ymouse, false)) {
this["button"+i].gotoAndStop(4); //
} else {
this["button"+i].gotoAndStop(1);
}
}
}
};
for (var i = 1; i<=total; i++) {
this["button"+i].onPress = function() {
this.gotoAndStop(4); //
};
}
Re: button movie kglad
1/21/2006 9:02:46 PM
for (var i = 1; i<=total; i++) {
this["button"+i].onPress = function() {
for(var j=1;j<=total;j++){
this._parent["button"+j].gotoAndStop(1);
}
this.gotoAndStop(4); //
};
Re: button movie dirkness
1/22/2006 12:28:18 AM
thanx for that kglad - but it's not working - the button when clicked isn't
staying down - going to frame 4.

i entered the script at the end of the existing script - i assume this was
correct?

presumably the parent refered to switches buttons other than the current 1 to
up (frame 1) and the current button to down (frame 4) - but that's not the
effect - is there an issue with the way I pasted in the new script?

thanx again - revised script below:

stop();
loadMovieNum("http://www.dirksmith.com/flash_2/photo1.swf",10);
total = 7;
this.onEnterFrame = function() {
for (var i = 1; i<=total; i++) {
if (this["button"+i]._currentframe != 7) {
if (this["button"+i].hitTest(_xmouse, _ymouse, false)) {
this["button"+i].gotoAndStop(4);
} else {
this["button"+i].gotoAndStop(1);
}
}
}
};
for (var i = 1; i<=total; i++) {
this["button"+i].onPress = function() {
this.gotoAndStop(4);
};
}


for (var i = 1; i<=total; i++) {
this["button"+i].onPress = function() {
for(var j=1;j<=total;j++){
this._parent["button"+j].gotoAndStop(1);
}
this.gotoAndStop(4); //
};
}
AddThis Social Bookmark Button