# Passing movieclip to function

**URL:** <https://forum.kirupa.com/t/passing-movieclip-to-function/241657>\
**Category:** flash\
**Created:** [October 16, 2007, 5:29pm UTC](https://forum.kirupa.com/t/passing-movieclip-to-function/241657 "2007-10-16T17:29:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bardic](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bardic/32/3708_2.png) [@bardic](https://forum.kirupa.com/u/bardic)\
**Post date:** [October 16, 2007, 5:29pm UTC](https://forum.kirupa.com/t/passing-movieclip-to-function/241657/1 "2007-10-16T17:29:36Z")

</div>

```auto
function spawnTextFields(target:MovieClip,fieldName:String,txt:String,depth:Number,aSize:String,xLoc:Number,yLoc:Number){

    [target].createTextField([fieldName],5,0,0,0,0);
    [target][fieldName].text = [txt];
    [target][fieldName]._x = xLoc;
    [target][fieldName]._y = yLoc;
    [target][fieldName].autoSize = [aSize];
}

spawnTextFields(this,"cat","meow",0,"left",10,10);

```

Can anyone explain to me how to get my target variable in my function to work? I am trying to make it the movieclip in which to make the text field. Any help would be much appreciated.
