# Loop through all the movie clips of a scene

**URL:** <https://forum.kirupa.com/t/loop-through-all-the-movie-clips-of-a-scene/182598>\
**Category:** Uncategorized\
**Created:** [March 19, 2006, 10:14pm UTC](https://forum.kirupa.com/t/loop-through-all-the-movie-clips-of-a-scene/182598 "2006-03-19T22:14:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ieatcotten](https://avatars.discourse-cdn.com/v4/letter/i/3da27b/32.png) [@ieatcotten](https://forum.kirupa.com/u/ieatcotten)\
**Post date:** [March 19, 2006, 10:14pm UTC](https://forum.kirupa.com/t/loop-through-all-the-movie-clips-of-a-scene/182598/1 "2006-03-19T22:14:32Z")

</div>

I am trying to apply a color matrix filter to all movie clips in a movie. I would like to do this without knowing the instance name of any of the clips. Does anyone know a way to loop through all the movie clips of a scene regardless of the names or number of clips.

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [March 19, 2006, 10:56pm UTC](https://forum.kirupa.com/t/loop-through-all-the-movie-clips-of-a-scene/182598/2 "2006-03-19T22:56:46Z")

</div>

```auto
for (var prop in this) {
 if (this[prop] instanceof MovieClip) {
  this[prop].filters = new Array(myColorMatrixFilter);
 }
}

```

---

<div class="post-metadata">

**Author:** ![ieatcotten](https://avatars.discourse-cdn.com/v4/letter/i/3da27b/32.png) [@ieatcotten](https://forum.kirupa.com/u/ieatcotten)\
**Post date:** [March 19, 2006, 11:24pm UTC](https://forum.kirupa.com/t/loop-through-all-the-movie-clips-of-a-scene/182598/3 "2006-03-19T23:24:45Z")

</div>

Thanks, that’s great code. It works perfect.

Here is what I ended up with.

```auto

import flash.filters.ColorMatrixFilter;
var theColorMatrixFilter = new flash.filters.ColorMatrixFilter();
var theBWMatrixFilter = new flash.filters.ColorMatrixFilter();

var bwFilters:Array = new Array(theBWMatrixFilter);
var bwFilterMatrix:Array = new Array(0.3, 0.59, 0.11, 0, 0, 0.3, 0.59, 0.11, 0, 0, 0.3, 0.59, 0.11, 0, 0, 0, 0, 0, 1, 0);
bwFilters[0].matrix = bwFilterMatrix;

var colorFilters:Array = new Array(theColorMatrixFilter);
var colorFilterMatrix:Array = new Array(1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0);
colorFilters[0].matrix = colorFilterMatrix;
    
bwBT.onPress = function(){
    for (var object in _root) {
         if (_root[object] instanceof MovieClip) {
              _root[object].filters = bwFilters;
         }
    }
}

colorBT.onPress = function(){
    for (var object in _root) {
         if (_root[object] instanceof MovieClip) {
              _root[object].filters = colorFilters;
         }
    }
}

```
