Reputation: 471
I'm trying to make a water system where the water particles collide with each other, but I keep getting this error.
[object water]
TypeError: Error #1010: A term is undefined and has no properties.
at science_fla::MainTimeline/feed()
Here is the code:
import flash.events.MouseEvent;
import com.coreyoneil.collision.CollisionList;
//etc
stop();
stage.addEventListener(MouseEvent.CLICK,feed);
function feed(event:MouseEvent)
{
var wat:water = new water(event.target.mouseX,event.target.mouseY);
MovieClip(root).addChild(wat);
particles.push(wat);
for(var i = 0; i < particles.length;i++)
{
if (particles[i]!=wat)
{
trace(particles[i]);
wat.myCollision.addItem(particles[i]);
}
particles.myCollision.addItem(wat);
}
}
Thanks for all of your help. If you need more code, just ask.
Upvotes: 0
Views: 103
Reputation: 359
I think you are accessing the variable which is not defined earlier. Actually your question is difficult to understand. Please let me know more code and which line it's got error. Or try that water variable not on certain function make it to global. and try . And also let me know what that water variables contains it has movieclip or any thing.?
Upvotes: 0
Reputation: 39458
I would say the issue is this line:
particles.myCollision.addItem(wat);
particles
is an array, and arrays don't have the property myCollision
.
Did you mean particles[i].myCollision
?
Upvotes: 1