Okay i want to make it that when a ball hits a wall, it will dissapear, and in its place a new movie clip appears, i got the hitTest down and the visiblity, but i dont know how to attach teh movie to its location.
Well, if you had something like
onClipEvent(enterFrame){
if(this.HitTest("wall"){
this._visible=false;
}
}
Then you could do something like this I suppose.
onClipEvent(enterFrame){
if(this.HitTest("wall"){
_root.attachMovie("explosionClip","explosion",this._depth);
_root.explosion._y=this._y;
_root.explosion._x=this._x;
this._visible=false;
}
}
Will that for you?
thanks a ton for the help, its working fine. I have have 1 more question, is there a way i can combine hitTests? something like…
if (this.hitTest(_root.block, _root.block1, _root.block2)) and so forth?
for that, you could use the logical operators.
[AS]
//logical OR: ||
if(1>2 || 2>1){
//do stuff…
}
//gets executed because the second condition is true
//logical AND: &&
if(1>2 && 2>1){
//do stuff…
}
//does not get executed because only one of the conditions is true.
[/AS]
Thnx njs, thats working quite well for me. I know i said that was my last question but i have one more. Is there a way to void an action, like after it has been executed once, it can not be used again?
-
You could delete the event handler:
[AS]myMovieClip.onEnterFrame = function() {
// statement(s)
if (this.hitTest(this._parent.myOtherClip)) {
// statement(s)
delete this.onEnterFrame;
}
};[/AS]
This method only works for dynamic event handlers.
http://www.kirupa.com/developer/actionscript/tricks/dynamicevent.asp -
Use a variable:
[AS]onClipEvent (enterFrame) {
// statement(s)
if (!myVar && this.hitTest(this._parent.myOtherClip)) {
// statement(s)
myVar = true;
}
}[/AS]