Stupid question

Hi all,
Okay, I know this is a stupid question, but I cannot figure it out!
Please help!
Here’s the simple problem:

I have 3 buttons. And I want them to move to a different position (gradually, not jump there) when one of them is clicked.
I wrote a function that is called whenever one of the buttons is clicked. The problem is that, the positions of the buttons only change by 5 pixels every time i click one of them. how do I make it so that, when i click one of them, they automatically move to the right positions? Thanks!

function buttonTrigger() {
if (_root.cSchool._y<700) {
_root.cSchool._y = _root.cSchool._y-5;
_root.cPro._y = _root.cPro._y+5;
_root.cPer._y = _root.cPer._y+5;
} else {
_root.cSchool._y = 300;
_root.cPro._y = 700;
_root.cPer._y = 700;
//this function is called here

That’s because you move your button in the on(release) handler. The on(release) handler only gets called when you hit the button.

To get fluid motion over several frames you need to put the code in a handler that gets called more than once, and then move the button a bit each time.

A great place to put something like this is in a Movieclip’s onEnterFrame handler. That gets called for every frame (typically 12 times a second). I don’t know if a button also has a onEnterFrame event. If it does, then that would be a good candidate also.

Hope that helps

Thanks for your reply. I understand why I can’t get the fluid motion…I was just wondering if there’s any way of getting what I want (ie fluid movement on click of a button not on entering a frame)? Or do I have to use tweening? Thanks!

by the way, the button is actually a movie clip…

i’m not sure, but i think you mean something like this.
just take a look


hmm…not quite what i meant, but thanks anyway!

I think this script is what you want:

Button.prototype.easeTo = function(x,y){
	var mc = _root.createEmptyMovieClip(this._name+"_ease",6523+Button.count);
	var btn = this
	mc.onEnterFrame = function(){
		btn._x = x-(x-btn._x)/1.2;
		btn._y = y-(y-btn._y)/1.2;
		btn._x > x-1 && btn._x < x+1 ? this.removeMovieClip() : null
// Usage
yourbutton.onRelease = function(){