# Lunch Chooser

**URL:** <https://forum.kirupa.com/t/lunch-chooser/177085>\
**Category:** contests\
**Created:** [January 30, 2006, 5:03am UTC](https://forum.kirupa.com/t/lunch-chooser/177085 "2006-01-30T05:03:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![foomonger](https://avatars.discourse-cdn.com/v4/letter/f/e19b73/32.png) [@foomonger](https://forum.kirupa.com/u/foomonger)\
**Post date:** [January 30, 2006, 5:03am UTC](https://forum.kirupa.com/t/lunch-chooser/177085/1 "2006-01-30T05:03:49Z")

</div>

More useful than interesting.

```auto

/*
www.foomonger.com
Lunch Chooser
Always trying to figure out where to go for lunch? Let the Lunch Chooser decide for you.
*/

// list your favorite lunch spots here
var lunchSpots_array:Array = ["Blue Ribbon", "New Asia", "Panera", "Stella's", "Cambridge Common", "Matilda's"];
var shakeInterval:Number;
var shakesCount:Number = 0;

// init the text field
this.createTextField("tf", 0, 0, 0, 190, 100);
this["tf"].selectable = false;
this["tf"].border = true;
var my_fmt:TextFormat = new TextFormat();
my_fmt.align = "center";
this["tf"].setNewTextFormat(my_fmt);
this["tf"].text = "Where should we go for lunch?
Click to find out.";

// set the mouse event
this.onMouseUp = startShake;

// start the shake interval
function startShake():Void {
    clearInterval(shakeInterval);
    shakesCount = 0;
    shakeInterval = setInterval(this, "runShake", 50);
}

// shake the text field
function runShake():Void {
    this["tf"]._x = (this["tf"]._x == 0) ? 6 : 0;
    this["tf"].text = lunchSpots_array[Math.round(Math.random() * (lunchSpots_array.length - 1))];
    updateAfterEvent();
    if (shakesCount++ > 25) {
        stopShake();        
    }
}

// stop the shake interval and find out where you're going to lunch
function stopShake():Void {
    clearInterval(shakeInterval);
    shakesCount = 0;
    this["tf"]._x = 0;
    this["tf"].text = "We're going to " + lunchSpots_array[random(lunchSpots_array.length)] + ".
Don't feel like it?
Click to try again.";
}

```
