# How to shorten this scripts?

**URL:** <https://forum.kirupa.com/t/how-to-shorten-this-scripts/235316>\
**Category:** flash\
**Created:** [August 10, 2007, 7:05am UTC](https://forum.kirupa.com/t/how-to-shorten-this-scripts/235316 "2007-08-10T07:05:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![youwh](https://avatars.discourse-cdn.com/v4/letter/y/82dd89/32.png) [@youwh](https://forum.kirupa.com/u/youwh)\
**Post date:** [August 10, 2007, 7:05am UTC](https://forum.kirupa.com/t/how-to-shorten-this-scripts/235316/1 "2007-08-10T07:05:03Z")

</div>

I have some scripts that almost doing same thing, but just different buttons, how should i shorten it down? Cause i would have a lot, ■■■■ lot function to write :s  
\*the buttons are not dynamic created so i would be easier to do some other stuff.

```auto

lv1_bsp1.onPress = function() {
    shop1();
    lv1_shp1.gotoAndPlay("play");
};
lv1_bsp2.onPress = function() {
    shop2();
 lv1_shp2.gotoAndPlay("play");
};
lv1_bsp3.onPress = function() {
    shop3();
 lv1_shp3.gotoAndPlay("play");
};
lv1_bsp4.onPress = function() {
    shop4();
 lv1_shp4.gotoAndPlay("play");
};
lv1_bsp5.onPress = function() {
    shop5();
 lv1_shp5.gotoAndPlay("play");
};

/////////////////////////////////
function shop1() {
    this.clear();
    lv1_shp2.gotoAndStop(1);
    lv1_shp3.gotoAndStop(1);
    lv1_shp3.gotoAndStop(1);
    lv1_shp4.gotoAndStop(1);
    lv1_shp5.gotoAndStop(1);
    this.lineStyle(2,0xFF0000);
    this.dashTo(lv1_pt._x,lv1_pt._y,lv1_pt1._x,lv1_pt1._y,4,8);
    this.dashTo(lv1_pt1._x,lv1_pt._y,lv1_shp1._x,lv1_shp1._y,4,8);
}
function shop2() {
    this.clear();
    lv1_shp1.gotoAndStop(1);
    lv1_shp3.gotoAndStop(1);
    lv1_shp3.gotoAndStop(1);
    lv1_shp4.gotoAndStop(1);
    lv1_shp5.gotoAndStop(1);
    this.lineStyle(2,6719658);
    this.dashTo(lv1_pt._x,lv1_pt._y,lv1_pt2._x,lv1_pt2._y,4,8);
    this.dashTo(lv1_pt2._x,lv1_pt2._y,lv1_shp2._x,lv1_shp2._y,4,8);
}
function shop3() {
    this.clear();
v1_shp1.gotoAndStop(1);
    lv1_shp1.gotoAndStop(1);
    lv1_shp2.gotoAndStop(1);
    lv1_shp4.gotoAndStop(1);
    lv1_shp5.gotoAndStop(1);
    this.lineStyle(2,6719658);
    this.dashTo(lv1_pt._x,lv1_pt._y,lv1_pt3._x,lv1_pt3._y,4,8);
    this.dashTo(lv1_pt3._x,lv1_pt3._y,lv1_shp3._x,lv1_shp3._y,4,8);
}
function shop4() {
    this.clear();
v1_shp2.gotoAndStop(1);
    lv1_shp1.gotoAndStop(1);
    lv1_shp2.gotoAndStop(1);
    lv1_shp3.gotoAndStop(1);
    lv1_shp5.gotoAndStop(1);
    this.lineStyle(2,6719658);
    this.dashTo(lv1_pt._x,lv1_pt._y,lv1_pt4._x,lv1_pt4._y,4,8);
    this.dashTo(lv1_pt4._x,lv1_pt4._y,lv1_shp4._x,lv1_shp4._y,4,8);
}
function shop5() {
    this.clear();
    lv1_shp1.gotoAndStop(1);
     lv1_shp2.gotoAndStop(1);
     lv1_shp3.gotoAndStop(1);
     lv1_shp4.gotoAndStop(1);
    this.lineStyle(2,6719658);
    this.dashTo(lv1_pt._x,lv1_pt._y,lv1_pt5._x,lv1_pt5._y,4,8);
    this.dashTo(lv1_pt5._x,lv1_pt5._y,lv1_shp5._x,lv1_shp5._y,4,8);
}

```
