# Dynamicaly creating functions

**URL:** <https://forum.kirupa.com/t/dynamicaly-creating-functions/24854>\
**Category:** Uncategorized\
**Created:** [July 6, 2003, 5:42am UTC](https://forum.kirupa.com/t/dynamicaly-creating-functions/24854 "2003-07-06T05:42:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zylum](https://avatars.discourse-cdn.com/v4/letter/z/d26b3c/32.png) [@zylum](https://forum.kirupa.com/u/zylum)\
**Post date:** [July 6, 2003, 5:42am UTC](https://forum.kirupa.com/t/dynamicaly-creating-functions/24854/1 "2003-07-06T05:42:22Z")

</div>

hi,

how would i go about dynamically making a function… im making a Tile Based World level editor and when the user is done editing a level, then they hit a button and a couple of for loops runs through all the tiles checking the x,y and tile type. then i want this information to be parameters within sub functions within the main function. so the as would look something like this  
[AS]subFunction = function () {  
//do this  
}  
//the above function is already defined in the script  
generateWorld = function () {  
subFunction (x,y,tileType)//a function is called for each tile in world  
subFunction (x,y,tileType)  
//etc…  
}  
//the above function (generateWorld) is created dynamically[/AS]

then in the next frame, the generate world function is called.

how would i do this. would i store the information in a multidimensional array? how would i dynamically create a function???

i hope i was clear with what im trying to accomplish,

thanks in advance,

-zylum

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 6, 2003, 6:08am UTC](https://forum.kirupa.com/t/dynamicaly-creating-functions/24854/2 "2003-07-06T06:08:09Z")

</div>

i don’t quite get you :(… why exactly does ‘generate world’ need to be declared dynamically?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 6, 2003, 6:28pm UTC](https://forum.kirupa.com/t/dynamicaly-creating-functions/24854/3 "2003-07-06T18:28:49Z")

</div>

well it’s going to be different everytime time so… is there a better way to get around this?
