# Help optimising code

**URL:** <https://forum.kirupa.com/t/help-optimising-code/225372>\
**Category:** flash\
**Created:** [May 11, 2007, 2:37am UTC](https://forum.kirupa.com/t/help-optimising-code/225372 "2007-05-11T02:37:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![force10x](https://avatars.discourse-cdn.com/v4/letter/f/d07c76/32.png) [@force10x](https://forum.kirupa.com/u/force10x)\
**Post date:** [May 11, 2007, 2:37am UTC](https://forum.kirupa.com/t/help-optimising-code/225372/1 "2007-05-11T02:37:43Z")

</div>

Hi all,  
I’m a noobie, struggling with AS2.  
I have 6 movieClips in my movie that have the same actions.  
is there any way I can use a single code for all of them instead of repeating the code everytime.

my code is as below.

```auto
 
//code for contact section
this.dottedPlants_mc.contactAni_mc.onRollOver = function() {
	this.gotoAndPlay("shake");
}

this.dottedPlants_mc.contactAni_mc.onRollOut = function() {
	this.gotoAndPlay("start");
}

this.dottedPlants_mc.conractAni_mc.onRelease = function() {
	trace("contact clicked");
}
//code for email section
this.dottedPlants_mc.emailAni_mc.onRollOver = function() {
	this.gotoAndPlay("shake");
}

this.dottedPlants_mc.emailAni_mc.onRollOut = function() {
	this.gotoAndPlay("start");
}

this.dottedPlants_mc.emailAni_mc.onRelease = function() {
	trace("email clicked");
}

```

thank you for your time and help
