View Full Version : adding a movie clip
dAEL
July 18th, 2003, 11:58 PM
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.
upuaut
July 19th, 2003, 03:30 AM
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?
dAEL
July 19th, 2003, 12:31 PM
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?
λ
July 19th, 2003, 04:28 PM
for that, you could use the logical operators.
//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.
dAEL
July 19th, 2003, 08:54 PM
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?
kode
July 19th, 2003, 10:31 PM
1) You could delete the event handler:
myMovieClip.onEnterFrame = function() {
// statement(s)
if (this.hitTest(this._parent.myOtherClip)) {
// statement(s)
delete this.onEnterFrame;
}
};
This method only works for dynamic event handlers.
http://www.kirupa.com/developer/actionscript/tricks/dynamicevent.asp
2) Use a variable:
onClipEvent (enterFrame) {
// statement(s)
if (!myVar && this.hitTest(this._parent.myOtherClip)) {
// statement(s)
myVar = true;
}
}
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.