Q: I want a movieclip to stop when it hits a wall?
A: Put this code inside the player-controlled movieclip. Remember, 2 should be the same as the speed of your player.
_______________________________________________________________________________________
onClipEvent (enterFrame) {
if (_root.level.hitTest(_x+(_width/2), _y, true)) {
this._x -= 2;
}
if (_root.level.hitTest(_x-(_width/2), _y, true)) {
this._x += 2;
}
if (_root.level.hitTest(_x, _y+(_height/2), true)) {
this._y -= 2;
}
if (_root.level.hitTest(_x, _y-(_height/2), true)) {
this._y += 2;
}
}
_______________________________________________________________________________________
Q: I want a movieclip to stop on frame 2 inside itself when it touches a movieclip called “goo”?
A: Put this code inside the player-controlled movieclip.
_______________________________________________________________________________________
onClipEvent (enterFrame) {
if (_root.level.hitTest(_x+(_width/2), _y, true)) {
this.gotoAndStop(2);
}
if (_root.level.hitTest(_x-(_width/2), _y, true)) {
this.gotoAndStop(2);
}
if (_root.level.hitTest(_x, _y+(_height/2), true)) {
this.gotoAndStop(2);
}
if (_root.level.hitTest(_x, _y-(_height/2), true)) {
this.gotoAndStop(2);
}
}
_______________________________________________________________________________________
Q: I want a movieclip to make the main timeline go to frame 2 when it touches another movielcip called “thing”?
A: Put this code inside the player-controlled movieclip.
_______________________________________________________________________________________
onClipEvent (enterFrame) {
if (_root.level.hitTest(_x+(_width/2), _y, true)) {
_root.gotoAndStop(2);
}
if (_root.level.hitTest(_x-(_width/2), _y, true)) {
_root.gotoAndStop(2);
}
if (_root.level.hitTest(_x, _y+(_height/2), true)) {
_root.gotoAndStop(2);
}
if (_root.level.hitTest(_x, _y-(_height/2), true)) {
_root.gotoAndStop(2);
}
}
_______________________________________________________________________________________
March 9, 2008 at 09:22 pm
….Maybe it’s just me but I can’t see any code under the “Put this code inside the player-controlled movieclip”….
March 9, 2008 at 09:19 pm
YES! That was my trick to see if anybody would leave a comment! AND IT WORKED!
HA! Do you usually visit this site? Thanks for the comment.
And don’t worry, I WILL PUT THE CODE THERE. Thanks again for the comment, really apreciate it.
March 9, 2008 at 09:54 pm
LOL ur a classic, eaglevision!!
March 10, 2008 at 10:58 pm
Thanks…I just have to put the code today…bye!
March 10, 2008 at 10:54 pm
….yeah….it worked……-_o
Nope, I just stumbled over it while testing Google Blog search and looking for Flash-based blogs. What a strange result I got…..
March 10, 2008 at 10:03 pm
Thanks…I am glad you found it, do you like it? Any suggestions? Are you learning anything or are you a guru? Thanks…I really apreciate it, not many people leave comments, thanks for taking the time. Thanks again.
April 23, 2008 at 23:35 pm
hallo the good woork
April 23, 2008 at 23:45 pm
Thanks
April 25, 2008 at 25:21 pm
Hmmm… interesting tutorial to get me started of in the world of Actionscript- I’m still a newb
I found this using tutorialized search
April 25, 2008 at 25:28 pm
Thank you!
Please email me if you need ANY help!
You can also sign up in the forums, which you will find in the top of this page. (where the buttons are).
Anyways, nice to have you here, request a tutorial! I will most likely make it
Cheers!
April 27, 2008 at 27:08 pm
hey eaglevision nice tutorial! i didn’t know you made tutorials only way i know you is from your movies on newground ps why so random 10 owns
anyways this is helping me with my new zombie game that i’m
most likley releasing, so thaks.
April 27, 2008 at 27:58 pm
Thank you for visiting!
Movies on newground? Hmm..I don’t remember making any movies. Just a game called “Lonely Pong” is the only thing I have on NG so far.
Once again, thanks for leaving a comment!
May 2, 2008 at 02:49 pm
hi eaglevision..
sorry but I’m not speak english very well….(I’m Italian)
anyway your site it’s very nice…..
thank’s for your help….
nice tutorial
May 2, 2008 at 02:05 pm
Nice to meet you!
I hope you stay around.
Don’t worry, I can understand everything.
Thank YOU, I love comments
Is there anything else you need help in, I can make a tutorial.
May 3, 2008 at 03:30 pm
Hi,
Great tutorials, they worked well.
Would it be possible if i could have a tutorial that when an object (controlled with keyboard, which i have already done) hits another object (named box_mc) it changes a text box with no words inside to one saying something like ‘Hello’ ?
Thanks.
May 3, 2008 at 03:33 pm
Of course!
I’ll start working on it right now.
May 3, 2008 at 03:05 pm
Oh, I am done….You’ll see it on the homepage.
May 3, 2008 at 03:08 pm
[...] …on this post. [...]
May 4, 2008 at 04:06 am
i have a question
i have a movie clip called “ball”. it moves left and right, it could also jump
but how can i make it stay when it lands on other objects instead
of going threw them?
please help
ill apriciate it!
May 8, 2008 at 08:05 pm
‘Q: I want a movieclip to stop on frame 2 inside itself when it touches a movieclip called “goo”?
A: Put this code inside the player-controlled movieclip.’
that code there just confuses me, would this be easier?
onClipEvent (enterFrame) {
if (this.hitTest(_root.goo)) {
_root.character.gotoAndStop(2);
}
May 8, 2008 at 08:17 pm
Yes, that would be easier.
But that will hittest the blue box that flash puts on every movieclip, this code makes it hittest the visual part, more realistic.
It is confusing, but once you read it carefully, you understand it.
Hope this helped.
May 24, 2008 at 24:46 am
Lol, don’t worry, if my name mis-leads you, I only Spam in Spam zones, on forums.
NICE TUTORIAL!!
Loved it.
May 24, 2008 at 24:48 am
Oh and BTW, Jordan, TY, too.
Do you use Flash MX?
Because the code didn’t work on my Flash 8. But I made it work for it, here’s what I got:
onClipEvent (enterFrame) {
if (this.hitTest(_root.goo)) {
_root.character.gotoAndStop(2);
}
}
May 24, 2008 at 24:05 pm
@Spammaster
Lol!
Thanks, that might work, too, but I don’t think jordan is coming back.
oh well.
June 5, 2008 at 05:00 am
Hey thanks for this that was exactly what i was lookig for.
June 5, 2008 at 05:44 pm
np!
lol
Glad to help!
June 9, 2008 at 09:37 pm
ok, here is the deal. I’m kinda new to flash and i’m trying to put together a game where i have a cannon shoot asteroids. I have a movie clip named “asteroid” and i want it to play when i have another movieclip named cannonball hit into it. Inside the main timeline I have asteroid and i put this code into it
onClipEvent (enterFrame) {
if (_root.cannonball.hitTest(_x+(_width/2), _y, true)) {
asteroid.gotoAndPlay(2);
}
if (_root.cannonball.hitTest(_x-(_width/2), _y, true)) {
asteroid.gotoAndPlay(2);
}
if (_root.cannonball.hitTest(_x, _y+(_height/2), true)) {
asteroid.gotoAndPlay(2);
}
if (_root.cannonball.hitTest(_x, _y-(_height/2), true)) {
asteroid.gotoAndPlay(2);
}
}
What am i doing wrong that the asteroid is not playing its movieclip when the cannonball hits into it
remeber I’m a noob when it comes to this stuff
June 9, 2008 at 09:58 pm
Please go to eaglevision.890m.com/blog
the blog has been moved.
Thanks
June 9, 2008 at 09:01 pm
want me to re-post there?
June 9, 2008 at 09:10 pm
Yes please, thanks
June 11, 2008 at 11:06 am
How would you create a script where an object would go down the screen and when it was in a certain spot you had to press a button. Kinda like DDR or Guitar hero or Super crazy Guitar maniac deluxe. I would like to make a game kinda like that but cant find any scripts or tutorials for scripts like it.
hope you can help
June 11, 2008 at 11:25 pm
The blog has moved to eaglevision.890m.com/blog
See the header image.