# Passing parameters to a function

**URL:** https://forum.kirupa.com/t/passing-parameters-to-a-function/238668
**Category:** Uncategorized
**Created:** [September 13, 2007, 7:37pm UTC](https://forum.kirupa.com/t/passing-parameters-to-a-function/238668 "2007-09-13T19:37:24Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![perfecthill](https://avatars.discourse-cdn.com/v4/letter/p/c77e96/32.png) [@perfecthill](https://forum.kirupa.com/u/perfecthill)
#### Post date: [September 13, 2007, 7:37pm UTC](https://forum.kirupa.com/t/passing-parameters-to-a-function/238668/1 "2007-09-13T19:37:24Z")

</div>

Hi,

I’m new to AS3, but have written a piece of code in AS2 which I’m now trying to convert.

Basically I’ve got a movieclip (“grid1”) and in that there are a number of instances of the same movieclip (“g1”, “g2” etc) and in that is a textbox (“ans.text”). The code I worte passes the name of the movieclip click and takes the content of that textbox and passes it to a function which checks it.

on the button:

```auto

on (press){
    checkAns1p(this.ans.text, this);
}

```

the function:

```auto

function checkAns1p(myAns, referer) {
    if (myAns == sub_answer) {
        //do something
}

```

This works fine, the problem I am finding is now that AS3 does not use “on (press)” I don’t see how it’s possible to pass this information.

```auto

function checkAns(event:MouseEvent):void {
    selectedAns = grid1.g1.ans.text;
    if (selectedAns == subAns){
        trace("Correct!");
    }
}

```

If I hard code it as above then it works, but I don’t want to have to do this 32 times. Is there anyway to pass “this” across as I did in AS2?
