# Finding movieClips inside custom class with typeof

**URL:** https://forum.kirupa.com/t/finding-movieclips-inside-custom-class-with-typeof/112146
**Category:** Uncategorized
**Created:** [June 4, 2004, 2:30am UTC](https://forum.kirupa.com/t/finding-movieclips-inside-custom-class-with-typeof/112146 "2004-06-04T02:30:25Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![playfight\_mac\_c](https://avatars.discourse-cdn.com/v4/letter/p/a183cd/32.png) [@playfight\_mac\_c](https://forum.kirupa.com/u/playfight_mac_c)
#### Post date: [June 4, 2004, 2:30am UTC](https://forum.kirupa.com/t/finding-movieclips-inside-custom-class-with-typeof/112146/1 "2004-06-04T02:30:25Z")

</div>

I am trying to find a way of locating movieClips inside of a custom class, without using nested for loops, which is the way I created them across a grid. I have been searching for a long time now, knowing the answer somehow lies within typeof or instanceof, but I can’t get it to work - help!

[AS]  
// thanks to [http://www.robertpenner.com](http://www.robertpenner.com)  
MovieClip.prototype.drawRect = function(x1, y1, x2, y2) {  
with (this) {  
moveTo(x1, y1);  
lineTo(x2, y1);  
lineTo(x2, y2);  
lineTo(x1, y2);  
lineTo(x1, y1);  
}  
};  
/////////Custom Grid Class  
\_global.GridModel = function(width, height, str, gridType) {  
this.str = str;  
this.gridType = gridType;  
this.width = width;  
this.height = height;  
this.str = str;  
this.board = new Array();  
for (var i = 0; i\<400; i += this.str) {  
this.board = new Array();  
for (var j = 0; j\<400; j += this.str) {  
this.board[j] = new Object();  
this.board[j].id = i_this.height+j;  
this.board[j].c = \_root.attachMovie(“icon”, “icon”+this.board[j].id, this.board[j].id);  
this.board[j].c.\_x = i;  
this.board[j].c.\_y = j;  
this.board[j].c.gridType = this.gridType;  
this.board[j].c.redflag.lineStyle(0, 0xFF0000);  
this.board[j].c.redflag.beginFill(0xFF0000);  
this.board[j].c.redflag.drawRect(i, j, i+(this.str), j+(this.str));  
this.board[j].c.redflag.endFill;  
//trace(typeof this.board[j].c); // returns: movieclip  
}  
}  
};  
// starGrid, instance of GridModel  
starGrid = new GridModel(Stage.width, Stage.height, 25, “star” );  
ASBroadcaster.initialize(starGrid);  
//movieClip method for mouse click  
MovieClip.prototype.onPress = function() {  
starGrid.whoClips();  
};  
/custom method to find instances of MC’s in starGrid  
THIS IS NOT WORKING! I cannot get either the for…in, or  
type of, to identify the movieClips in my starGrid object/  
GridModel.prototype.whoClips = function() {  
trace(starGrid instanceof GridModel);//returns: true  
trace(typeof starGrid);//returns: object  
for (var i in starGrid) {  
if (typeof starGrid_ == movieclip) {  
trace(starGrid\*.\_name);  
}  
}  
};  
[/AS]
