# How do reduce duplicate code?

**URL:** <https://forum.kirupa.com/t/how-do-reduce-duplicate-code/235449>\
**Category:** flash\
**Created:** [August 11, 2007, 4:04am UTC](https://forum.kirupa.com/t/how-do-reduce-duplicate-code/235449 "2007-08-11T04:04:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![artcoder](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@artcoder](https://forum.kirupa.com/u/artcoder)\
**Post date:** [August 11, 2007, 4:04am UTC](https://forum.kirupa.com/t/how-do-reduce-duplicate-code/235449/1 "2007-08-11T04:04:46Z")

</div>

I found myself writing this code …

```auto

 
this.onRelease = function():Void {
  delete this.onEnterFrame;
  // and a bunch of code ehre
}

this.onReleaseOutside = function():Void {
  delete this.onEnterFrame;
  // and a bunch of code ehre

}
 

```

See how the two functions are identical. How can I re-write this so I’m not duplicating (copying and pasting) code?
