# Updating an AS2 slider bar

**URL:** https://forum.kirupa.com/t/updating-an-as2-slider-bar/294719
**Category:** flash
**Created:** [August 18, 2009, 10:46pm UTC](https://forum.kirupa.com/t/updating-an-as2-slider-bar/294719 "2009-08-18T22:46:36Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![architortured](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@architortured](https://forum.kirupa.com/u/architortured)
#### Post date: [August 18, 2009, 10:46pm UTC](https://forum.kirupa.com/t/updating-an-as2-slider-bar/294719/1 "2009-08-18T22:46:36Z")

</div>

Hello,  
I am new to the forums, as well as to Flash, and I had a question.  
I am just learning AS3, and have no idea whatsoever about the differences between 2 and 3. There is a bit of code from [http://flashexplained.com/menus-interfaces/how-to-make-a-minimalistic-vertical-menu-with-a-slider/](http://flashexplained.com/menus-interfaces/how-to-make-a-minimalistic-vertical-menu-with-a-slider/) that I wanted to update to use AS3, but it was written in AS2.  
Here it is:

var speed:Number = 9;  
menuButton1\_btn.onPress = menuButton2\_btn.onPress = menuButton3\_btn.onPress = menuButton4\_btn.onPress = menuButton5\_btn.onPress = menuButton6\_btn.onPress = function () {  
var clickedButtonPosition:Number = this.\_y;  
var currentSliderPosition:Number = \_root.slider\_mc.\_y;  
\_root.onEnterFrame = function() {  
\_root.slider\_mc.\_y += (clickedButtonPosition-currentSliderPosition)/speed;  
currentSliderPosition = \_root.slider\_mc.\_y;  
if (currentSliderPosition\>=(clickedButtonPosition-0.8) && currentSliderPosition\<=  
(clickedButtonPosition+0.8)) {  
currentSliderPosition = clickedButtonPosition;  
delete \_root.onEnterFrame;  
}  
};  
};

I get twelve total errors (there are six buttons with a slider next to them, and there are 2 types of errors). The first is: 1119: Access of possibly undefined property onPress through a reference with static type flash.display:SimpleButton. The other is 1120: Access of undefined property \_root. The key parts of the code (I think) are the button names, and slider\_mc., a little black square that slides up and down the height of the menu.

All of the buttons are button symbols, each with a unique name. I read that to fix the 1119 error, I can convert them to movie clips, but then they no longer function as buttons (which is sort of the point). Can anyone offer some advice?

Thank you in advance,  
-architortured
