This content has been marked as final. Show 2 replies
just scanning this briefly, I'd say that you'd be far better off using a shape based collision detection system like that of Grant Skinners - OR build your own system using Bitmap.hitTest (which is what Grant's uses but only compares two MC instances per iteration) I would also prefer to build a class for each ball instance, and have each instance run it's own checks against the entire field at once and track it's own properties, like heading, velocity, friction, type, color, etc. - then if a hit is determined pass the vector info to the other ball instance after performing the appropriate calculations OR pass them and have the receiving ball perform it's own vector modifications. This would save the lengthy process of testing each prop in a single pass as well - let each instance control itself in other words. There is some more discussion on hitTesting HERE and some bitmap hitTesting examples HERE (however they are running a bit slow atm since there are two within the post - normally my example run at around 22+fps with 40 instances) this should give you a few more thoughts on how to construct this. I realize that this doesn't really answer your query however, so...
to place instance into an array you write:
var my_array = [ instance1, instance2, ... instanceZ ];
to call an instance from an array you write:
my_array[index]._x = newXpos;
where 'index' is the value of the instance at that position in the array, remember that arrays are 'zero' based - that is the first index is 0. so to iterate through the entire array we use a FOR loop, this would create a 'new' property called 'instanceIndex' of the Object at that index in the array and assign it the value of it's current position in the array. just a basic example: