# Play MC within function... how?

**URL:** <https://forum.kirupa.com/t/play-mc-within-function-how/245141>\
**Category:** flash\
**Created:** [November 26, 2007, 8:35pm UTC](https://forum.kirupa.com/t/play-mc-within-function-how/245141 "2007-11-26T20:35:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![themoon201](https://avatars.discourse-cdn.com/v4/letter/t/c0e974/32.png) [@themoon201](https://forum.kirupa.com/u/themoon201)\
**Post date:** [November 26, 2007, 8:35pm UTC](https://forum.kirupa.com/t/play-mc-within-function-how/245141/1 "2007-11-26T20:35:44Z")

</div>

I have 6 movieclip buttons with actionscript. (btn1, btn2, etc)  
I have 6 movieclips that fade in text. (01\_mc, 02\_mc, etc)

When a btn receives an onRelease it moves to the top. But I also want it to play it’s corresponding movieclip. (btn1 = 01\_mc, btn2 = 02\_mc, etc

I know how to it like this:

```php

btn1.onRelease = function () {
        mc_fix.attachMovie ("01_mc", "o", 1, {_x:450, _y:-150});
btn1.onRollOut = function () {
        mc_fix.o.removeMovieClip();

```

However I can not put that into my current code as it does not work. I believe this may be beyond me. ☹

Current code:

```php

var _topXArray:Array = [90,90,90,90,90,90]
var _bottomXArray:Array = [50,125,200,270,350,425]
var _rotationArray:Array = [-90,-149,148,89,30,-30]
var _scaleArray:Array = [50,50,50,50,50,50]

// the y position when the single button moves to the top
var _topY:Number = 160;

// the y position for all the other buttons moving to the bottom
var _bottomY:Number = 310;

// loop through the buttons, giving each these paramaters
for (var i = 1; i <=6; i++) {
    var thisBtn = this["btn"+i];
    this["btn"+i].filters = [myBevelFilter]
    
    thisBtn.topX = _topXArray[i-1];
    thisBtn.bottomX = _bottomXArray[i-1];
    thisBtn.rotationTarget = _rotationArray[i-1];
    thisBtn.scaleTarget = _scaleArray[i-1];
    
    thisBtn.onRelease = function () {
        doAnim(this);
    }
}
}

function doAnim (whichClip:MovieClip) :Void {
    // loop through the buttons
    for (var i = 1; i <=6; i++) {
        var thisBtn = this["btn"+i];
        
        // if the current button is the one moving to the top then it moves to the top
        if (thisBtn == whichClip) {
            var myXTween:Tween = new Tween(thisBtn, "_x", mx.transitions.easing.Regular.easeOut, thisBtn._x, thisBtn.topX, 1, true);
            var myYTween:Tween = new Tween(thisBtn, "_y", mx.transitions.easing.Regular.easeOut, thisBtn._y, _topY, 1, true);
            var myRotationTween:Tween = new Tween(thisBtn, "_rotation", mx.transitions.easing.Regular.easeOut, thisBtn._rotation, thisBtn.rotationTarget+180, 1, true);
            var myScaleTween:Tween = new Tween(thisBtn, "_xscale", mx.transitions.easing.Regular.easeOut, thisBtn._xscale, thisBtn.scaleTarget+50, 1, true);
            var myScaleTween:Tween = new Tween(thisBtn, "_yscale", mx.transitions.easing.Regular.easeOut, thisBtn._yscale, thisBtn.scaleTarget+50, 1, true);            
        } 
        // otherwise it moves to the bottom
        else { 
            var myXTween:Tween = new Tween(thisBtn, "_x", mx.transitions.easing.Regular.easeOut, thisBtn._x, thisBtn.bottomX, 1, true);
            var myYTween:Tween = new Tween(thisBtn, "_y", mx.transitions.easing.Regular.easeOut, thisBtn._y, _bottomY, 1, true);
            var myRotationTween:Tween = new Tween(thisBtn, "_rotation", mx.transitions.easing.Regular.easeOut, thisBtn._rotation, thisBtn.rotationTarget, 1, true);
            var myScaleTween:Tween = new Tween(thisBtn, "_xscale", mx.transitions.easing.Regular.easeOut, thisBtn._xscale, thisBtn.scaleTarget, 1, true);
            var myScaleTween:Tween = new Tween(thisBtn, "_yscale", mx.transitions.easing.Regular.easeOut, thisBtn._yscale, thisBtn.scaleTarget, 1, true);            

        }
    }    
}

```

I’m assuming I have to stick it somehow in the doAnim but I do not know how. Please assist. 😕
