# Optimizing Code

**URL:** https://forum.kirupa.com/t/optimizing-code/206862
**Category:** flash
**Created:** [November 12, 2006, 1:32pm UTC](https://forum.kirupa.com/t/optimizing-code/206862 "2006-11-12T13:32:23Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![cki](https://avatars.discourse-cdn.com/v4/letter/c/85f322/32.png) [@cki](https://forum.kirupa.com/u/cki)
#### Post date: [November 12, 2006, 1:32pm UTC](https://forum.kirupa.com/t/optimizing-code/206862/1 "2006-11-12T13:32:23Z")

</div>

Hi,

An FLA is not attached as all is functioning. However, would the code be more elegant if the interface components where stored in an multi-dimensional array with the name, and coordinates as keys, and the attachMovie was called once from within a function?

If so would some kind soul illustrate how this is executed? If this is overkill for the code please inform.

```auto

/**

Code not relevant to question omitted.

**/
stop();
//
init();
//Start variable Declaration
var lotusTimeLine:Object = this;
var path:MovieClip = container_mc;
//end variable Declarations
// Import the Tween class and/or the easing package and filters.
import flash.filters.*;
//end import Declarations
//
function init():Void {
   //used to start the "show."
   buildInterface();
}
//

function buildInterface():Void {
   //called by init() to start the show.
   _root.createEmptyMovieClip("path", lotusTimeLine.getNextHighestDepth());
   //bg used to restrict the shadow to just the stage, not content of.
   path.attachMovie("bg", "bg_mc", lotusTimeLine.getNextHighestDepth());
   //
   path._x = Stage.width/2;
   path._y = Stage.height/2;
   createShadow(path, 4, 45, 0x000000, 0.4, 10, 10, 2, 3);
   //
   path.attachMovie("lotus_ripple", "lotusRipple_mc", path.getNextHighestDepth(), {_x:25, _y:100});
   //
   path.attachMovie("lotus", "lotus_mc", path.getNextHighestDepth());
   zoom(path.lotus_mc, 0, 2.5);
   //
   path.attachMovie("brand_01", "brand01_mc", path.getNextHighestDepth(), {_x:325, _y:100});
   //
   path.attachMovie("brand_02", "brand02_mc", path.getNextHighestDepth(), {_x:275, _y:115});
   //
   loadDrops();
}
function loadDrops() {
   path.attachMovie("drop_01", "drop01_mc", path.getNextHighestDepth(), {_x:-40, _y:-150});
   //
   path.attachMovie("drop_02", "drop02_mc", path.getNextHighestDepth(), {_x:-20, _y:75});
   //
   path.attachMovie("drop_03", "drop03_mc", path.getNextHighestDepth(), {_x:-150, _y:-50});
   //clearInterval(loadInterval);

}

```
