# Help With Width Size For Button Slider

**URL:** <https://forum.kirupa.com/t/help-with-width-size-for-button-slider/167075>\
**Category:** flash\
**Created:** [October 25, 2005, 8:46am UTC](https://forum.kirupa.com/t/help-with-width-size-for-button-slider/167075 "2005-10-25T08:46:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rai\_kane3](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@rai\_kane3](https://forum.kirupa.com/u/rai_kane3)\
**Post date:** [October 25, 2005, 8:46am UTC](https://forum.kirupa.com/t/help-with-width-size-for-button-slider/167075/1 "2005-10-25T08:46:24Z")

</div>

I have created a slider that moves under a said button when pressed, however I need the slider to resize when under that button relative to the button width.

So each button is given the instance name but incremented by one each time  
but1, but2 but3 upto but 12

and here is the action script where am I going wrong

```auto
stop();
MovieClip.prototype.ease = function(tar) {
	clearInterval(id);
	this.onEnterFrame = function() {
		this._x = tar-(tar-this._x)/1.2;
		if (Math.abs(tar-this._x)<1) {
			this._x = tar;
			delete this.onEnterFrame;
		}
	};
};
var pos = but1._x;
for (var i = 1; i<12; i++) {
	var btn = this[&quot;but&quot;+i];
	btn.id = i;
	btn.onRollOver = function() {
		slider.ease(this._x);
		trace(&quot;x = &quot; + this._x);
		trace(&quot;w = &quot; + this._width);
	};
	btn.onRollOut = function() {
		id = setInterval(slider, &quot;ease&quot;, 250, pos);
	};
	btn.onRelease = function() {
		pos = this._x;
		setButtons(this.id);
	};
}
	function setButtons(q) {
	for (var i = 1; i<12; i++) {
		var btn = this[&quot;but&quot;+i];
		if (i != q) {
			btn.enabled = 1;
			btn.gotoAndStop(1);
		} else {
			btn.enabled = 0;
			btn.gotoAndStop(2);
		}
	}
}
setButtons(1);

```
