# Looping through object properties

**URL:** <https://forum.kirupa.com/t/looping-through-object-properties/85798>\
**Category:** flash\
**Created:** [April 7, 2005, 3:54pm UTC](https://forum.kirupa.com/t/looping-through-object-properties/85798 "2005-04-07T15:54:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)\
**Post date:** [April 7, 2005, 3:54pm UTC](https://forum.kirupa.com/t/looping-through-object-properties/85798/1 "2005-04-07T15:54:46Z")

</div>

This is the file i have been playing about with basically it just loops through an array of properties.  
[![](http://static.hugedomains.com/images/logo_huge_domains.gif) ](http://static.hugedomains.com/images/logo_huge_domains.gif)  
here is the code used

```auto
k = 0;
function init() {
	obj0 = [{_xscale:100, _yscale:100}, {_x:500, _y:400}, {_xscale:300, _yscale:300}, {_xscale:50, _yscale:50}, {_x:700, _y:100}, {_rotation:90, _alpha:50}, {_xscale:200, _yscale:200}, {_xscale:100, _yscale:100}, {_x:500, _y:400}, {_rotation:-90, _alpha:100}];
	obj1 = [{_xscale:100, _yscale:100}, {_x:100, _y:300}, {_xscale:50, _yscale:50}];
	obj2 = [{_xscale:100, _yscale:100}, {_x:700, _y:100}, {_xscale:200, _yscale:200}];
	obj3 = [{_xscale:100, _yscale:100}, {_x:500, _y:400}, {_xscale:300, _yscale:300}];
}
MovieClip.prototype.ease = function(ob) {
	for (var prop in ob[0]) {
		this[prop] += (ob[0][prop]-this[prop])/5;
		if (Math.abs(ob[0][prop]-this[prop])<1) {
			this[prop] = ob[0][prop];
			//trace(ob[k][prop]);
			trace(ob[0][prop]);
			delete ob[0][prop];
			count++;
			if (count == 2) {
				ob.splice(0, 1);
				count = 0;
			}
			if (ob.length == 0) {
				delete this.onEnterFrame;
			}
		}
	}
};
init();
for (var i = 0; i<4; i++) {
	clip = this.attachMovie("btn", "btn"+i, i);
	clip._x = 200+clip._width*i;
	clip._y = 350;
	clip.ivar = i;
	clip.onPress = function() {
		init();
		mc.onEnterFrame = function() {
			this.ease(this._parent["obj"+arguments.callee.ivar]);
		};
		mc.onEnterFrame.ivar = this.ivar;
	};
}

```

This works fine as i have it but i am limited to only 2 properties per object within an array. So i couldn`t have {\_x:500, \_y:400,\_xscale:200,\_rotation:90} because of the count in the main function.(it does actually work to a point but is a little unpredicatable)  
Can anyone think of another way of checking the number of properties in each object  
edit/i already thought of including a count in each object but it just seems really inefficient.
