# Problem making flexible function!

**URL:** <https://forum.kirupa.com/t/problem-making-flexible-function/300272>\
**Category:** flash\
**Created:** [November 18, 2009, 3:45pm UTC](https://forum.kirupa.com/t/problem-making-flexible-function/300272 "2009-11-18T15:45:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gilo87](https://avatars.discourse-cdn.com/v4/letter/g/ed8c4c/32.png) [@gilo87](https://forum.kirupa.com/u/gilo87)\
**Post date:** [November 18, 2009, 3:45pm UTC](https://forum.kirupa.com/t/problem-making-flexible-function/300272/1 "2009-11-18T15:45:39Z")

</div>

Hi Guys,

I have just started learning AS3 (2-3 weeks) and I have to say its very enjoyable!

I am trying to make a function that pulls in values to save me writing 15 separate functions!

I have a “street mc” which has 15 “house mc’s” inside.  
When the user hovers over a house I want the resident to appear above the house.

The house instance name is house1 and there is a mc in the library linked using the MrsRoy() class.

This is my code so far:

```auto
var house1Res:MovieClip = new MrsRoy();
    

    function resIconIn(e:MouseEvent):void{
        var currentHouse = "street." + e.target.name;
        var currentRes = e.target.name + "Res";

        currentHouse.addChild(currentRes);
        currentRes.play();
        var fadeIn:Tween = new Tween(currentRes, "alpha", None.easeIn, 0, 1, 12, false);
        currentHouse.addEventListener(MouseEvent.MOUSE_OUT, resIconOut, false, 0, true);
    }
    
    
    function resIconOut(e:MouseEvent):void{
        var currentHouse = "street." + e.target.name;
        var currentRes = e.target.name + "Res";
        
        var fadeOut:Tween = new Tween(currentRes, "alpha", None.easeOut, 1, 0, 3, false);
        fadeOut.addEventListener(TweenEvent.MOTION_FINISH, onFinish, false, 0, true);
        removeEventListener(MouseEvent.MOUSE_OUT, resIconOut);
    }
    
    
    function onFinish(e:TweenEvent):void{
        var currentHouse = "street." + e.target.name;
        var currentRes = e.target.name + "Res";
        currentHouse.removeChild(currentRes);
    }

```

I get the error:

TypeError: Error #1006: value is not a function.  
at Dignity\_drive\_fla::MainTimeline/resIconIn()

Thanks in advance!
