# ActionScript 3 & tween

**URL:** <https://forum.kirupa.com/t/actionscript-3-tween/313474>\
**Category:** flash\
**Created:** [August 31, 2010, 4:33pm UTC](https://forum.kirupa.com/t/actionscript-3-tween/313474 "2010-08-31T16:33:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![GLotfi](https://avatars.discourse-cdn.com/v4/letter/g/5f8ce5/32.png) [@GLotfi](https://forum.kirupa.com/u/GLotfi)\
**Post date:** [August 31, 2010, 4:33pm UTC](https://forum.kirupa.com/t/actionscript-3-tween/313474/1 "2010-08-31T16:33:32Z")

</div>

Hey,  
let me tell you what I have on the scene.  
I have 7 buttons and 7 MovieClips, each button run a movieClip.  
Buttons are named like this (product1\_btn, product2\_btn product3\_btn …product7\_btn) .  
Movie clip are named almost as the buttons (product1\_btn\_mc … product7\_btn\_mc) so I have added just “\_mc” at the end.  
I want when I ROLL (OVER or OUT) on any button the Moviclip concerned play (tween Elastic animation).

The problem is the “Tween” doesnt do anything, when I rollover buttons nothing happens, and the MovieClip stay as it is.

Here is my code:  
//////////////////////////////// Beginning

import fl.transitions.Tween;  
import fl.transitions.easing.\*;

var XinTween:Tween;  
var YinTween:Tween;

var XoutTween:Tween;  
var YoutTween:Tween;

var TargetName:String;  
//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*ROLL\_OVER  
product1\_btn.addEventListener(MouseEvent.ROLL\_OVER, OVERProduct);  
product2\_btn.addEventListener(MouseEvent.ROLL\_OVER, OVERProduct);  
product3\_btn.addEventListener(MouseEvent.ROLL\_OVER, OVERProduct);  
product4\_btn.addEventListener(MouseEvent.ROLL\_OVER, OVERProduct);  
product5\_btn.addEventListener(MouseEvent.ROLL\_OVER, OVERProduct);  
product6\_btn.addEventListener(MouseEvent.ROLL\_OVER, OVERProduct);  
product7\_btn.addEventListener(MouseEvent.ROLL\_OVER, OVERProduct);

//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*ROLL\_OUT  
product1\_btn.addEventListener(MouseEvent.ROLL\_OUT, OUTProduct);  
product2\_btn.addEventListener(MouseEvent.ROLL\_OUT, OUTProduct);  
product3\_btn.addEventListener(MouseEvent.ROLL\_OUT, OUTProduct);  
product4\_btn.addEventListener(MouseEvent.ROLL\_OUT, OUTProduct);  
product5\_btn.addEventListener(MouseEvent.ROLL\_OUT, OUTProduct);  
product6\_btn.addEventListener(MouseEvent.ROLL\_OUT, OUTProduct);  
product7\_btn.addEventListener(MouseEvent.ROLL\_OUT, OUTProduct);

//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*ROLL\_OVER  
function OVERProduct(event:MouseEvent):void  
{  
Number  
TargetName = event.target.name;  
XinTween = new Tween([TargetName+"\_mc"],“scaleX”,Elastic.easeOut,1,2,.3,true);  
YinTween = new Tween([TargetName+"\_mc"],“scaleY”,Elastic.easeOut,1,2,.3,true);  
trace (“NomOVER “+[TargetName.valueOf()+”\_mc”] );  
}

//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*ROLL\_OUT  
function OUTProduct(event:MouseEvent):void  
{  
TargetName = event.target.name;  
XinTween = new Tween([TargetName+"\_mc"],“scaleX”,Elastic.easeOut,2,1,.8,true);  
YinTween = new Tween([TargetName+"\_mc"],“scaleY”,Elastic.easeOut,2,1,.8,true);  
trace ("NomOUT "+TargetName );  
}  
}

/////////////////////////////////// End

Notice:  
1- The trace work perfectly. On the output window it show the name of the MovieClip wanted but the tween doesnt play the animation.  
2- If i delete the square brackets " [] =\> [TargetName+"\_mc"] " On the output window it show an error (ReferenceError: Error #1056: Impossible to create the property scalex on String).

Please help.
