# Ok all you actionscript gurus, try this

**URL:** <https://forum.kirupa.com/t/ok-all-you-actionscript-gurus-try-this/231792>\
**Category:** Uncategorized\
**Created:** [July 8, 2007, 4:16am UTC](https://forum.kirupa.com/t/ok-all-you-actionscript-gurus-try-this/231792 "2007-07-08T04:16:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zwemg](https://avatars.discourse-cdn.com/v4/letter/z/bc79bd/32.png) [@zwemg](https://forum.kirupa.com/u/zwemg)\
**Post date:** [July 8, 2007, 4:16am UTC](https://forum.kirupa.com/t/ok-all-you-actionscript-gurus-try-this/231792/1 "2007-07-08T04:16:02Z")

</div>

Whats an easier way to write this code?

button\_btn.onRelease = function() {  
this.onEnterFrame = function() {  
if (\_root.\_currentframe == 1) {  
play();  
} else {  
this.onRelease = function() {  
this.onEnterFrame = function() {  
if (\_root.\_currentframe == 25) {  
play();  
}  
}  
}  
}  
}  
}

Basically Ive got a tween on the root timeline and it moves down between frames 1 to 25 and then back up from frame 25 to 50 and starts all over again.

Also how can I include all that code as a single function so I can just call it rather than writing the entire code again?

Thanks all
