# Passing a function around

**URL:** <https://forum.kirupa.com/t/passing-a-function-around/282662>\
**Category:** Uncategorized\
**Created:** [February 24, 2009, 10:09pm UTC](https://forum.kirupa.com/t/passing-a-function-around/282662 "2009-02-24T22:09:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![GrndMasterFlash](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@GrndMasterFlash](https://forum.kirupa.com/u/GrndMasterFlash)\
**Post date:** [February 24, 2009, 10:09pm UTC](https://forum.kirupa.com/t/passing-a-function-around/282662/1 "2009-02-24T22:09:41Z")

</div>

so, i think it’s just cause it’s the end of the day and my brain wants to quit, but i would like some input.

im trying to pass a function to a question box that when you click the YES button the function passed in will fire for some reason im having a hard time holding the function until the YES is clicked.

here is what i got

```auto

//the call that opens the choice box and sets the info the gui_obj part is cause the //funciton is in a separate class file
gui_obj.displayChoice("Add the cell phone to your inventory?", "YES", "NO", gui_obj.addToInventory(item))

//the function to set up everything
public function displayChoice(txt:String, yes:String, no:String, funk:Function)
        {
            panel_choice.txt.text = txt;
            panel_choice.yes.text = yes;
            panel_choice.no.text = no;
            //dtrace(funk+" as "+choiceFunction);
            choiceFunction = Function(funk);
            panel_choice.visible = true;
        }

```

any creative ideas on how to do this? :insomniac:
