I am trying to have an avatar collision in my file but I can't seem to understand how events happen.
The onMouseDown function controls the movement of the latest avatar on the stage, right?
I'm trying to have an event ocurr when the character collides against another avatar so, I guess the first one's position variables are updated in the onUserVariablesUpdate function.
I placed a conditional loop in the mouseDown function to see what clips are on stage so I know the collision is happening :
Code: Select all
for (j=0; j<userList_lb.length; j++) {
var a:Object = userList_lb.getItemAt(j).data;
// trace("a = "+a);
var b:MovieClip = board["clip_"+a];
// trace("b.gender = "+b.gender+newline);
// trace("myAvatar.gender = "+myAvatar.gender+newline);
if (myAvatar.gender != b.gender && myAvatar.character.hitTest(b.character)) {
trace(newline+"myAvatar Hit bClip"+newline);
}
}
I see it only traces when myAvatar hitTests the other file and I'm attaching an example clip when the collision happens but I don't see how to control the visibility of the avatars from there.
Should I, perhaps try to create a variable to resend to the onUserVariablesUpdate ?