# 1 Btn-different events

**URL:** https://forum.kirupa.com/t/1-btn-different-events/279807
**Category:** flash
**Created:** [January 19, 2009, 4:29pm UTC](https://forum.kirupa.com/t/1-btn-different-events/279807 "2009-01-19T16:29:40Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![michey](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@michey](https://forum.kirupa.com/u/michey)
#### Post date: [January 19, 2009, 4:29pm UTC](https://forum.kirupa.com/t/1-btn-different-events/279807/1 "2009-01-19T16:29:40Z")

</div>

Hi  
Need some help with this:

```php
 
//Speed vars
min_speed = 1;
max_speed = 6;
beschleunigung = 1.03;
speed = 1.6;
//Clips pos
mc1._x = 0;
mc2._x = mc1.width;
mc3._x = 2*mc2.width;
mc4._x = 3*mc1.width;
 
//Changepoint
change_point = -(2*mc1._width);
//Bool vars
var drive:Boolean;
var acceleration:Boolean;
var deceleration:Boolean;
 
// _______________________________________________________________________________
// _______________________________________________________________________________
//Deceleration and stop
function anhalten() {
speed = Math.max(speed, min_speed);
this.onEnterFrame = function() {
speed>min_speed ? speed /= beschleunigung : speed=min_speed=0;
move_Clips();
};
}
// _______________________________________________________________________________
// _______________________________________________________________________________
//Default drive
function fahren() {
this.onEnterFrame = function() {
speed = 6;
move_Clips();
};
}
// _______________________________________________________________________________
// _______________________________________________________________________________
//Restart with acceleration 
function anfahren() {
speed = Math.max(speed, min_speed);
this.onEnterFrame = function() {
 
speed<max_speed ? speed *= beschleunigung : speed=max_speed;
move_Clips();
};
}
// _______________________________________________________________________________
// _______________________________________________________________________________
//Clips loop
function move_Clips() {
for (var i = 1; i<=4; i++) {
var myClips = this["mc"+i];
myClips.filters=new Array(new flash.filters.BlurFilter(2,0,2))
myClips._x -= speed;
if (myClips._x<=change_point) {
myClips._x += this._width;
}
}
}
// _______________________________________________________________________________
// _______________________________________________________________________________
//Btn events
my_btn.onRelease = function() {
if () {
trace(deceleration.valueOf());
this.gotoAndStop(2);
anhalten();
test_Txt.text = "ANHALTEN";
} else {
trace(acceleration.valueOf());
this.gotoAndStop(1);
anfahren();
test_Txt.text = "ANFAHREN";
}
};
// _______________________________________________________________________________
// _______________________________________________________________________________
fahren();//default drive

```

What I want to achieve is that the btn can stop the default drive by starting the function anhalten and then it should be able to restart with the function anfahren…  
I think this should go with if/else and bool-vars, but I could not make it work.  
Thanks for any help.
