# Creating a "toolbox" - how would I code this efficiently?

**URL:** <https://forum.kirupa.com/t/creating-a-toolbox-how-would-i-code-this-efficiently/308753>\
**Category:** flash\
**Created:** [April 29, 2010, 11:48am UTC](https://forum.kirupa.com/t/creating-a-toolbox-how-would-i-code-this-efficiently/308753 "2010-04-29T11:48:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![IQAndreas](https://avatars.discourse-cdn.com/v4/letter/i/f08c70/32.png) [@IQAndreas](https://forum.kirupa.com/u/IQAndreas)\
**Post date:** [April 29, 2010, 11:48am UTC](https://forum.kirupa.com/t/creating-a-toolbox-how-would-i-code-this-efficiently/308753/1 "2010-04-29T11:48:39Z")

</div>

I really have no idea how to ask this question, but I’ll try anyway.

A project I’m helping out with requires multiple tools (like the various types of pen and brush tools in most paint programs).

The tools are things like  
_\>Create wall tool  
\>Create room tool  
\>Resize tool  
\>Move tool  
\>Delete tool  
\>Pan tool_  
etc.

I have no idea how to code this, though.

Something like this would be REALLY inefficient, cluttered, and difficult to add tools to:

```auto
//This function is run every time the mouse is down (duh)
function onMouseDown(ev:MouseEvent)
{
   select case (currentTool)
   {
      case wallTool : 
          ...
      case roomTool : 
          ...
      case moveTool : 
          ...
      // etc.
   }
}

//Same for the following functions
function onMouseUp() { ... }
function onMouseMove() { ... }

```

And I want to make it easy to add new tools without hassle.

Any ideas?
