Groups | Blog | Home
all groups > flash actionscript > january 2006 >

flash actionscript : Using button instance name


Lorien_oj
1/8/2006 10:20:11 PM
Hello

I think this should be easy, but I havetn found a way around it :(

I have a set of buttons on my stage. Thay are links to other places on the
timeline. Thay all have instanse name that are the same as the place on the
timeline thay are linked to. My question:

I want a simple script to put on all the buttons that gets the instence name
of the button and send the time line there on release.

I tries this:

on (release) {
_root.gotoAndStop(this._name);
}

This works well on movieclips but not on buttons. Can anyone help me?? It's
not a big problem, I just want to solve it

thanx
kglad
1/9/2006 2:09:18 AM
i think it would be a lot easier and make more sense to use movieclip buttons.
but the following should work for any button that's 25x25 or less. (you can
adjust the 25 to suit your needs):

on (press) {
for (obj in this) {
if (Math.abs(this[obj]._x-this._xmouse)<25 &&
Math.abs(this[obj]._y-this._ymouse)<25) {
this.gotoAndStop(obj);
}
}
}
Lorien_oj
1/9/2006 6:53:03 PM
thanx - wil try that now

AddThis Social Bookmark Button