PDA

View Full Version : Collision reaction


90ne1
02-25-2009, 07:41 PM
I am making a flash game using Macromedia flash 2004 and was attempting to play a frame when item Player Dot came in contacted with Dot. I continuously edit it and keep getting error messages. Any help would be appreciated.

onClipEvent (enterFrame) {}
if (_root.Dot,
hitTest(_root.Player Dot)) {
gotoAndPlay(4);

kkbbcute
02-26-2009, 10:06 AM
Your code is completely wrong, you closed the enterFrame function before it even started, and you never did close your if statement. I recommend borrowing a few books from your local library to help you get started, it works!

EDIT: M1KE gave an excellent example.

M1KE
02-26-2009, 09:08 PM
It should be:

onClipEvent (enterFrame) {
if (_root.Dot.hitTest(_root.Player Dot)) {
gotoAndPlay(4);
}
}

90ne1
02-27-2009, 10:55 AM
-.- Thanks for the help guys, Ive been looking around for some manuals at the library and online, havnt really gotten the hang of it yet.

kkbbcute
03-01-2009, 11:23 AM
-.- Thanks for the help guys, Ive been looking around for some manuals at the library and online, havnt really gotten the hang of it yet.

You'll get used to it eventually, try using code assist for like a month till you get used to it, a helps a little with syntax errors.

90ne1
03-01-2009, 07:09 PM
Clipboard Actions: Line 1: Clip events are permitted only for movie clip instances
onClipEvent (enterFrame) {

Clipboard Actions: Line 2: ')' or ',' expected
if (_root.Dot.hitTest(_root.Player Dot)) {

Clipboard Actions: Line 5: Unexpected '}' encountered
}


It would not allow me to imput the code into MF

kkbbcute
03-02-2009, 08:00 AM
Clipboard Actions: Line 1: Clip events are permitted only for movie clip instances
onClipEvent (enterFrame) {

Clipboard Actions: Line 2: ')' or ',' expected
if (_root.Dot.hitTest(_root.Player Dot)) {

Clipboard Actions: Line 5: Unexpected '}' encountered
}


It would not allow me to imput the code into MF

I think you tried placing all this code on a frame, as seen from the error in your first line.

cjx3711
03-03-2009, 11:50 AM
You need to place the code on a movieclip not a frame if you want to place the code on a frame it would be like this:

onEnterFrame = function () {
if (_root.Dot.hitTest(_root.Player Dot)) {
gotoAndPlay(4);
}
}

kkbbcute
03-03-2009, 11:52 AM
You need to place the code on a movieclip not a frame if you want to place the code on a frame it would be like this:

onEnterFrame = function () {
if (_root.Dot.hitTest(_root.Player Dot)) {
gotoAndPlay(4);
}
}

In AS3 you would have to do it like this:

addEventListener("enterFrame", onEnterFrame);
function onEnterFrame(evt:Event) {
//Code here
}

cjx3711
03-04-2009, 02:51 AM
I'm quite sure 90ne1 is using AS2, don't confuse him

kkbbcute
03-04-2009, 04:39 AM
I'm quite sure 90ne1 is using AS2, don't confuse him

Just saying for reference.
And you can never be sure if he needs it in the future as well, quite a few people use AS2 now but are trying to learn AS3 you know.

cjx3711
03-05-2009, 11:26 AM
On a somewhat unrelated topic, in AS3, what is the point of giving a name to the on enter frame listener?

kkbbcute
03-05-2009, 12:06 PM
On a somewhat unrelated topic, in AS3, what is the point of giving a name to the on enter frame listener?

Dunno, its one of those things that you just copy because everyone does it and thus you assume that it's part of the code of something.

But seriously, if there is a reason other than for identification, I have no idea.