# Arrays

**URL:** <https://forum.kirupa.com/t/arrays/186978>\
**Category:** Uncategorized\
**Created:** [April 25, 2006, 7:41pm UTC](https://forum.kirupa.com/t/arrays/186978 "2006-04-25T19:41:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![g5604](https://avatars.discourse-cdn.com/v4/letter/g/54ee81/32.png) [@g5604](https://forum.kirupa.com/u/g5604)\
**Post date:** [April 25, 2006, 7:41pm UTC](https://forum.kirupa.com/t/arrays/186978/1 "2006-04-25T19:41:05Z")

</div>

hi,

is it possible to store an array inside another array? i have an array which holds various filters and i want to apply cmFilter to [4] of that array

```php
    var matrix:Array = new Array(amount, 0, 0, 0, 0, 0, amount, 0, 0, 0, 0, 0, amount, 0, 0, 0, 0, 0, amount, 0);
    var cmFilter:ColorMatrixFilter = new ColorMatrixFilter(matrix);
    path.curr_effects[4] = [cmFilter];
    path.curr_chan.filters = path.curr_effects;

```

cheers.  
Gareth

---

<div class="post-metadata">

**Author:** ![virusescu](https://avatars.discourse-cdn.com/v4/letter/v/8edcca/32.png) [@virusescu](https://forum.kirupa.com/u/virusescu)\
**Post date:** [April 25, 2006, 8:43pm UTC](https://forum.kirupa.com/t/arrays/186978/2 "2006-04-25T20:43:50Z")

</div>

you can easily create a multidimensionall array in flash like this.

```auto
a1 = [1,2,3,4];
a2 = [5,6,7,8];
a = [a1,a2];
trace(a[0][1]);// will trace 2
//OR
a3 = [[1,2,3],[4,["a","b"],6],[7,8,9]];
trace(a3[2][2]);// will trace 9;
trace(a3[1][1]);// will trace a,b (this is actually another array);
trace(a3[1][1][0]);// will trace a;

```

Hope it’s clear enough, 'cause I don’t understand your problem with the code :).

---

<div class="post-metadata">

**Author:** ![g5604](https://avatars.discourse-cdn.com/v4/letter/g/54ee81/32.png) [@g5604](https://forum.kirupa.com/u/g5604)\
**Post date:** [April 25, 2006, 9:09pm UTC](https://forum.kirupa.com/t/arrays/186978/3 "2006-04-25T21:09:25Z")

</div>

hi thanks for you reply… basically i have an array called **curr\_effects** and i want to add the array **cmFilter** to its number 4 slot. and then apply the curr\_effects array to [COLOR=#000000][COLOR=#0000bb]curr\_chan[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]filters[/COLOR][/COLOR]

---

<div class="post-metadata">

**Author:** ![virusescu](https://avatars.discourse-cdn.com/v4/letter/v/8edcca/32.png) [@virusescu](https://forum.kirupa.com/u/virusescu)\
**Post date:** [April 26, 2006, 6:53am UTC](https://forum.kirupa.com/t/arrays/186978/4 "2006-04-26T06:53:16Z")

</div>

Ok. I now understand. So. The filters parameter of an MC is an array of filters like (dropshadow, glow etc).  
Here’s your problem - path.curr\_effects[4] = **[cmFilter]**;  
You add as the fourth element of the curr\_effects array another array with only one element cmFilter. You need to add directly the cmFilter to the array because in the end you will use the array of filters. An array of arrays of filters is not useful :). So you actually don’t need to store an array inside another array.  
So the code would look like

```auto
var matrix:Array = new Array(amount, 0, 0, 0, 0, 0, amount, 0, 0, 0, 0, 0, amount, 0, 0, 0, 0, 0, amount, 0);
    var cmFilter:ColorMatrixFilter = new ColorMatrixFilter(matrix);
    path.curr_effects[4] = cmFilter;
    path.curr_chan.filters = path.curr_effects; 

```

Writing this I’ve realized that you might want your path.curr\_effects to hold multiple possible combinations of filters. Because this might be the case where you would want to keep an array inside another array.  
So storing your array was the good way, as long as you previously defined path.curr\_effects = new Array();  
If you done this you will be able to set Strings, numbers, arrays or objects as elements of that array.  
so path.curr\_effects[3] = [1,2,3]; // stores another array at the fourth element of path.curr\_effects array.  
In this case the problem is when you set your current array to the filters. You need to get only the array of filters. If inside a multidimensional array you will need to speciffy the element like this

```auto
var matrix:Array = new Array(amount, 0, 0, 0, 0, 0, amount, 0, 0, 0, 0, 0, amount, 0, 0, 0, 0, 0, amount, 0);
    var cmFilter:ColorMatrixFilter = new ColorMatrixFilter(matrix);
    path.curr_effects[4] = [cmFilter];
    path.curr_chan.filters = path.curr_effects[4]; 

```

Hope this helps you.
