# Code optimization

**URL:** https://forum.kirupa.com/t/code-optimization/212031
**Category:** flash
**Created:** [January 7, 2007, 9:24pm UTC](https://forum.kirupa.com/t/code-optimization/212031 "2007-01-07T21:24:11Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ceh](https://avatars.discourse-cdn.com/v4/letter/c/5fc32e/32.png) [@ceh](https://forum.kirupa.com/u/ceh)
#### Post date: [January 7, 2007, 9:24pm UTC](https://forum.kirupa.com/t/code-optimization/212031/1 "2007-01-07T21:24:11Z")

</div>

Hi dear experts… I am sure that this code can be optimized so I don’t have to type 8 instances (only 2 shown) of the (almost) same code… Any hints?[INDENT][SIZE=1]kabinet.onRollOver = function() {[/SIZE]  
[SIZE=1] this.fleka.\_alpha = 70;[/SIZE]  
[SIZE=1] this.izlaz=false;[/SIZE]  
[SIZE=1] }[/SIZE]  
[SIZE=1]  
kabinet.onRollOut = function() {[/SIZE]  
[SIZE=1] this.izlaz=true;[/SIZE]  
[SIZE=1] this.filters = “”;[/SIZE]  
[SIZE=1] }[/SIZE]

[SIZE=1] kabinet.onPress = function() {[/SIZE]  
[SIZE=1] this.filters = smudi;[/SIZE]  
[SIZE=1] }[/SIZE]

[SIZE=1] kabinet.onRelease = function() {[/SIZE]  
[SIZE=1] this.filters = “”;[/SIZE]  
[SIZE=1] }[/SIZE]

[SIZE=1] //---------------------------[/SIZE]

[SIZE=1] operativni.onRollOver = function() {[/SIZE]  
[SIZE=1] this.fleka.\_alpha = 70;[/SIZE]  
[SIZE=1] this.izlaz=false;[/SIZE]  
[SIZE=1] }[/SIZE]  
[SIZE=1]  
operativni.onRollOut = function() {[/SIZE]  
[SIZE=1] this.izlaz=true;[/SIZE]  
[SIZE=1] this.filters = “”;[/SIZE]  
[SIZE=1] }[/SIZE]

[SIZE=1] operativni.onPress = function() {[/SIZE]  
[SIZE=1] this.filters = smudi;[/SIZE]  
[SIZE=1] }[/SIZE]

[SIZE=1] operativni.onRelease = function() {[/SIZE]  
[SIZE=1] this.filters = “”;[/SIZE]  
[SIZE=1] }[/SIZE]  
[/INDENT]What I am aiming for is to have a way to pass “kabinet”, or “operativni” etc. to a function or smth… The code is used to control mc buttons on the stage. It works, but it’s ugly and not practical, obviously…

I tried with[SIZE=1]  
[/SIZE][INDENT][SIZE=1][_var_]onRollOver = function() {…[/SIZE]  
[/INDENT]inside a function, _var_ being the parameter of said function (“kabinet”, “operativni” etc.), but to no avail. Also tried with the with(_var_), thingy, but with the same result.

Any hints?
