# Need a person to write Simple Array for me

**URL:** https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446
**Category:** Uncategorized
**Created:** [August 10, 2004, 12:10am UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446 "2004-08-10T00:10:32Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Brandon](https://avatars.discourse-cdn.com/v4/letter/b/f08c70/32.png) [@Brandon](https://forum.kirupa.com/u/Brandon)
#### Post date: [August 10, 2004, 12:10am UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/1 "2004-08-10T00:10:32Z")

</div>

Don’t think im dumb are anything but i need someone to write a simple array for me though all my actionscripting ive never had to do it before and I really dont have the time to learn now. Let me descirbe what has to be done really simple and then ill send you a test dummy to add the code to. The game this is for is almost completed and is one of my best creations yet.  
Description:  
My game consists of thousands of hit tests that all work together to stop the unit from running though small objects. (mostly alot of trees and walls).  
I know nothing about arrays. Heres the simple hit test all you have to do is make the number after T everynumber possible.  
if (this, hitTest(\_root.world.T+\*)) {  
okay if you accept this job you will be included in the Credits. The file is attached, when done send it to (with the name you want to be known as under the credits):  
[Darktemplarian8@aol.com](mailto:Darktemplarian8@aol.com)

---

<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: [August 10, 2004, 12:12am UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/2 "2004-08-10T00:12:55Z")

</div>

oh ya the file is just for you to work with it isnt the game just a tensil to write the code on and send to me. Note the tensil does contain all the movement code so you can test it. Just wanted to clear that up.

---

<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: [August 10, 2004, 6:04pm UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/3 "2004-08-10T18:04:16Z")

</div>

how many numbers are there? in the fla there are 2 T integers and 4B integers… do you want B to be included as well?  
and btw this isnt just a simple array job either…

Prophet.

---

<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: [August 10, 2004, 6:28pm UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/4 "2004-08-10T18:28:27Z")

</div>

yes T is for only trees and B is for the Misc objects like walls and stuff

---

<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: [August 10, 2004, 6:30pm UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/5 "2004-08-10T18:30:42Z")

</div>

so are you going to try and write an array for me becuase i am almost done with most of the games major codings then im going to start the maps Story line and i really need that code for my unit.

---

<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: [August 10, 2004, 10:29pm UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/6 "2004-08-10T22:29:34Z")

</div>

like i said im almost done with my coding for my Game and need to test out a few other things so someone please just write the code and send me the thing please I want to start testing my games quests and other code as soon as possible. k thanks

---

<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: [August 10, 2004, 11:38pm UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/7 "2004-08-10T23:38:12Z")

</div>

keep ya wig on ill give it a whirl but im not sure…  
ne others want to hav a crack at it be my guest

Prophet.

PS ill PROBABLY (no promises) be on again tomoro (lookin at the time its actually later today…) at 6pm GMT

---

<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: [August 11, 2004, 1:08am UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/8 "2004-08-11T01:08:46Z")

</div>

Sounds Great like he said Please if anyone else wants give it a try. Thanks agian.

---

<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: [August 12, 2004, 4:52am UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/9 "2004-08-12T04:52:07Z")

</div>

yes i’m still waiting for anyone to try and figure this out had a few views but no real help except Prophet who seems to help alot of people. K someone reply with some help.

---

<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: [August 12, 2004, 10:17pm UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/10 "2004-08-12T22:17:39Z")

</div>

thanks i do my best 😉  
altho i gotta admit im a lil 2 busy to giv urs (or that musical rotating ball thingy :S) enough time atm im afraid…

i log on every day (if i can) and help other ppl coz it helps me in cementing the basics and broadening my own experience 🙂 id reccomend helping to all those question askers out there! 😉 lol

Prophet.

---

<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: [August 12, 2004, 11:50pm UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/11 "2004-08-12T23:50:59Z")

</div>

well any others i would highly like you to look at my FLA and try and write an array for it if you could. Thanks becuase im not getting far working on it myself

---

<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: [August 13, 2004, 1:31am UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/12 "2004-08-13T01:31:33Z")

</div>

Here’s a related question:

I start with a variable called allnumbers:

```auto
 for (allnumbers=0; allnum<50; allnum++) {
trace("_root.world.T"+allnum);
}

```

and the output looks like this:

```auto

_root.world.T0
_root.world.T1
_root.world.T2
_root.world.T3 
...
_root.World.T49

```

How do I use this variable to perform a hit test on multiple instances (\_root.world.T1, \_root.world.T2…)? I thought that something like this would work:

```auto
 if (_root.Unit, hitTest(_root.world.T+allnumbers)) {...}

```

…but it doesn’t

---

<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: [August 13, 2004, 1:41am UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/13 "2004-08-13T01:41:18Z")

</div>

Ya im confused by this too and ive tryed about every way possible the only way ive been told this can be done is with and array and i dont know anything about them and have gone far without using them and i dont want to learn them just for this reason. If you can’t figure it out just do the long way:

if (\_root.Unit, hitTest(\_root.World.Tree1) or \_root.Unit, hitTest(\_root.World.Tree2) or \_root.Unit, hitTest(\_root.World.Tree3)) { ext… lol

Oh ya someone please Help me on the real priority if you could find the code i know it would help alot of game Actionscripters. Thanks

---

<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: [August 13, 2004, 4:37am UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/14 "2004-08-13T04:37:47Z")

</div>

Add this to the top of the blue dudes AS

```auto

onClipEvent(load){
	numTrees = 6;
	checkTrees = function(){
		for(var i = 1; i< numTrees+1; i++){
			if(this, hitTest(_root.world["T"+i])){
				return 1;
			}
		}
	}
}

```

then Instead of using if(this, hitTest()) blah blah blah for each direction, just replace it with this…

```auto

if (checkTrees()) {

```

Copy the trees and number them T1, T2, T3, T4, T5 etc… so if you use 5 trees, you would have T1-T5 and the numTrees variable would be 5. If you use 6 trees, change the numTrees variable to 6, etc… etc…

Here’s the .fla (had to zip it, too big… sorry).

Oh yeah… no Array required either. I’m not sure what this talk of “B” is, but this should give you some ideas. Maybe make something like this

```auto

onClipEvent(load){
	numTrees = 6;
	checkTrees = function(){
		for(var i = 1; i< numTrees+1; i++){
			if(this, hitTest(_root.world["T"+i])){
				return 1;
			}
		}
	}

	numObjects = 4;
	checkObjects = function(){
		for(var i = 1; i< numObjects+1; i++){
			if(this, hitTest(_root.world["B"+i])){
				return 1;
			}
		}
	}

}

```

and then change the if…

```auto

if (checkTrees() && checkObjects()) {

```

I didn’t test the objects, but I tested the trees…

---

<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: [August 13, 2004, 5:26pm UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/15 "2004-08-13T17:26:55Z")

</div>

Thanks  
Just one more thing your middle code, if you have both hit tests should be or like this,  
if (checkTrees() or checkObjects()) {  
thanks again.

---

<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: [August 13, 2004, 6:18pm UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/16 "2004-08-13T18:18:17Z")

</div>

yer thas probly y i culdnt think of a simple way of doing this! lol

```auto
if((checkTrees() || checkObjects()){
}

```

sorry i couldnt b of more help tho ☹

Prophet.

---

<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: [August 13, 2004, 7:54pm UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/17 "2004-08-13T19:54:43Z")

</div>

Can someone please explain what the last line of the function does?

```auto

onClipEvent(load){
 numTrees = 6;
 checkTrees = function(){
  for(var i = 1; i< numTrees+1; i++){
   if(this, hitTest(_root.world["T"+i])){
   ** return 1;
** }
  }
 

```

---

<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: [August 13, 2004, 9:48pm UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/18 "2004-08-13T21:48:29Z")

</div>

> [@Mike D](#):
>
> Can someone please explain what the last line of the function does?
> 
> ```auto
> 
> onClipEvent(load){
> numTrees = 6;
> checkTrees = function(){
> for(var i = 1; i< numTrees+1; i++){
> if(this, hitTest(_root.world["T"+i])){
> ** return 1;
> ** }
> }
>  
> 
> ```

Just like the normal hitTest() function, it returns 1 if there there is indeed a “hit” and returns 0 if there isn’ a hit, which is what makes the if(checkTrees()){ work.

---

<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: [August 14, 2004, 12:49am UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/19 "2004-08-14T00:49:29Z")

</div>

note that boolean values true or false can be substituted for 1s and 0s…  
hence y the if statement works if there has been a hit - the function has returned true and therefore sets off the if statement 😉

Prophet.

---

<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: [August 14, 2004, 1:23am UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446/20 "2004-08-14T01:23:02Z")

</div>

Thanks, I thought that may have been the case.

[Next page](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/60446.md?page=2)
