# Array Isn't Detected In Parameter

**URL:** https://discourse.processing.org/t/array-isnt-detected-in-parameter/862
**Category:** Coding Questions
**Created:** [June 11, 2018, 3:30am UTC](https://discourse.processing.org/t/array-isnt-detected-in-parameter/862 "2018-06-11T03:30:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Avid\_Coder](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Avid\_Coder](https://discourse.processing.org/u/Avid_Coder)
#### Post date: [June 11, 2018, 3:30am UTC](https://discourse.processing.org/t/array-isnt-detected-in-parameter/862/1 "2018-06-11T03:30:17Z")

</div>

I am trying to make an animation system to display images with a certain frame rate. While attempting to pass the function an array, it said I had not created an array or variable with that name. I tried adding square brackets to no avail. I also tried changing some syntax in the declaration of the array, declaring the PImages then sending them to the array and even putting the array in different scopes.

Declaration:

```auto
PImage idleDev[] = {loadImage("IdleDev1.png"), loadImage("IdleDev2.png")};

```

Use In Method:

```auto
animation(x, y, (int)frameRate/2, idleDev, 2, (float)playerWidth, (float)playerHeight);

```

Any ideas to fix this? It has been pissing me off for the past hour!

---

<div class="post-metadata">

### Author: ![noahbuddy](https://avatars.discourse-cdn.com/v4/letter/n/73ab20/32.png) [@noahbuddy](https://discourse.processing.org/u/noahbuddy)
#### Post date: [June 11, 2018, 5:28am UTC](https://discourse.processing.org/t/array-isnt-detected-in-parameter/862/2 "2018-06-11T05:28:42Z")

</div>

Without more of your code to work from, I would guess this is a scope problem.  
If idleDev is declared as-is in setup() then draw() would not be able to see it.

You would need two parts to make everything happy.

```
// global variable (outside any function)
PImage idleDev[];

```

Then

```
// inside setup()
idleDev = new PImage[]{loadImage("moon.bmp"), loadImage("smallmoon.bmp")};

```

Also a good idea to test inside draw() that idleDev != null before calling animation().

---

<div class="post-metadata">

### Author: ![Avid\_Coder](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Avid\_Coder](https://discourse.processing.org/u/Avid_Coder)
#### Post date: [June 11, 2018, 3:35pm UTC](https://discourse.processing.org/t/array-isnt-detected-in-parameter/862/3 "2018-06-11T15:35:30Z")

</div>

Thanks, I’ll go try that out now!

---

<div class="post-metadata">

### Author: ![Avid\_Coder](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Avid\_Coder](https://discourse.processing.org/u/Avid_Coder)
#### Post date: [June 11, 2018, 3:40pm UTC](https://discourse.processing.org/t/array-isnt-detected-in-parameter/862/4 "2018-06-11T15:40:28Z")

</div>

It appears to have worked, now I can finally continue, Thank You!
