# Returning a value from a mouse event?

**URL:** <https://forum.kirupa.com/t/returning-a-value-from-a-mouse-event/283768>\
**Category:** Uncategorized\
**Created:** [March 10, 2009, 10:03pm UTC](https://forum.kirupa.com/t/returning-a-value-from-a-mouse-event/283768 "2009-03-10T22:03:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vols4ever](https://avatars.discourse-cdn.com/v4/letter/v/cab0a1/32.png) [@vols4ever](https://forum.kirupa.com/u/vols4ever)\
**Post date:** [March 10, 2009, 10:03pm UTC](https://forum.kirupa.com/t/returning-a-value-from-a-mouse-event/283768/1 "2009-03-10T22:03:40Z")

</div>

Hello all,

This seems simple to do yet I can not find the right way to do it. I have a button here’s the code:

```
    public function goForward(event:MouseEvent):void{
            s++;
        if (s == xmlData.Player.length()){
            s = 0;
        }

      }

```

Now all I want to do is have this function return a number so I can set up a new variable. I know I need to replace the “void” with “Number” data type and use “return” in the function. But I just can’t find the right way to write the code. “s” is initially set to zero so basically all I want is when “s” increments up, it changes the new variable as well( call it newNum if you want) Any and all help is greatly appreciated. Thank you.
