# Dynamic Tween

**URL:** https://forum.kirupa.com/t/dynamic-tween/201608
**Category:** flash
**Created:** [September 22, 2006, 11:00pm UTC](https://forum.kirupa.com/t/dynamic-tween/201608 "2006-09-22T23:00:19Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ekazda](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ekazda/32/556_2.png) [@ekazda](https://forum.kirupa.com/u/ekazda)
#### Post date: [September 22, 2006, 11:00pm UTC](https://forum.kirupa.com/t/dynamic-tween/201608/1 "2006-09-22T23:00:19Z")

</div>

So I’m a huge supporter of trying to make my code reusable. I’m trying to build a tween with actionscript that I can use on a number of different object, depending on what variable I load into the function. However, I’m having a hard time writing the code.

So, I have a button, that calls a function:

```auto
on(rollOver){
 _root.fadeLogo(1, "out")
}
on(rollOut, dragOut){
 _root.fadeLogo(1, "in")
}

```

Then I have a function in the root of the movie:

```auto
function fadeLogo(logoNumber, fadeEffect){
if (fadeEffect=="out"){
   fadeClientLogo = new Tween("clientGridMC.logoHolder"+logoNumber, "_alpha", Normal.easeOut, "clientGridMC.logoHolder"+logoNumber+"._alpha", 0, .1, true)
  }else{
   fadeClientLogo = new Tween(("clientGridMC.logoHolder"+logoNumber, "_alpha", Normal.easeOut, "clientGridMC.logoHolder"+logoNumber+"._alpha", 100, .1, true)
  }
 }
}

```

However, this doesn’t seem to do anything. I need this for a project going out on Tuesday. Any help would be GREAT! I would hate to have to simply duplicate this code 16 times simply to change a few numbers.
