# \[Flash8\]AS Help needed! Hard time in optimizing

**URL:** <https://forum.kirupa.com/t/flash8-as-help-needed-hard-time-in-optimizing/220321>\
**Category:** flash\
**Created:** [March 25, 2007, 3:23am UTC](https://forum.kirupa.com/t/flash8-as-help-needed-hard-time-in-optimizing/220321 "2007-03-25T03:23:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![adamlewen](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@adamlewen](https://forum.kirupa.com/u/adamlewen)\
**Post date:** [March 25, 2007, 3:23am UTC](https://forum.kirupa.com/t/flash8-as-help-needed-hard-time-in-optimizing/220321/1 "2007-03-25T03:23:57Z")

</div>

Hi all, new both here and in the AS world.  
In the past couple of days I have had a very hard time in optimizing some code for an application I am creating.  
In that application I have 12 Movie Clips to be triggered by the user,  
these 12 objects are Tile1, Tile2, Tile3 etc…  
When I am using the same piece of code for each Tile, everything works, but I am repeating each Tile code 12(!) times…

Example code:  
[FONT=Arial Narrow][SIZE=3]//Make Tile1-------------------/_/ Make Tile1 Functions  
function makeTile1() {  
Tile1Holder = root.createEmptyMovieClip(“Tile1Holder”, this.getNextHighestDepth());  
for (var i = 0; i\<1; i++) { // I might change the i\<x and it has nothing to do with my //prob.  
var Tile1:MovieClip = Tile1Holder.attachMovie(“Tile1”, "Tile1"+i, Tile1Holder.getNextHighestDepth());  
Tile1Array_ = Tile1;  
Tile1.\_x = 80  
Tile1.\_y = 35  
};  
}  
//Make Tile2-------------------/_/ Make Tile2 Functions  
function makeTile2() {  
Tile2Holder = root.createEmptyMovieClip(“Tile2Holder”, this.getNextHighestDepth());  
for (var i = 0; i\<1; i++) {  
var Tile2:MovieClip = Tile2Holder.attachMovie(“Tile2”, "Tile2"+i, Tile2Holder.getNextHighestDepth());  
Tile2Array_ = Tile2;  
Tile2.\_x = 120  
Tile2.\_y = 35  
};  
}  
//--------End example[/SIZE][/FONT]  
These are 2 blocks out of the 12 I am using now…  
I have been trying various ways to make one block work for all 12, but I am really out of luck.  
It might be useful to add that each Tile has a  
var Tile1Array = new Array();  
declared  
and a  
makeTile1();  
later on in the code.

Any thought? Help will be so GREATLY appreciated!  
Thanks for reading me.
