Forum Topic: coding problems (skipping lines)

(214 views • 15 replies)

This topic is 1 page long.

<< < > >>
Mad as Hell

iamironman

Reply To Post Reply & Quote

Posted at: 6/15/09 09:30 AM

iamironman DARK LEVEL 13

Sign-Up: 08/05/06

Posts: 388

HOLY! sheet.

ok, so im nearing the end of a course in game design (for school ya know). and I'm making game in flash, so i thaught what better place to go for help.

mostly it has gone smoothly, and a good part of the game is finished, but im having a problem at a turning point, and i have ABSOlutly NO idea WTF is going on.

so im making a camera follow the ball, but (on the main timeline not the MC) the code doesent seem to geting to the onEnterFrame!

so wtf could possably make a script skip over / not get to a certain line of code.
we have prety much combed the entire program, and we cant find an effing thing wrong.

onMouseDown = function () {
	sling = false;
};
onMouseUp = function () {
	cam.stopDrag();
	sling = true;
};
onEnterFrame = function () {
	if (!cam.hitTest(ball) && holder == false) {
		cam.stopDrag();
		sling = true;
	}
	if (sling == true) {
		ydiff = _root.ball._y-cam._y+ycamset;
		xdiff = _root.ball._x-cam._x+xcamset;
		cam._x += xdiff*speed;
		cam._y += ydiff*speed;
	} else if (sling == false) {
		cam.startDrag(false);
	}
}

yeah, cant figure out what the problem is.

(\_/)
( '.' )
(")(") this is bunny, copy and paste him to your forum signaturse to help him gain world domination


None

Alpharius120

Reply To Post Reply & Quote

Posted at: 6/15/09 09:37 AM

Alpharius120 FAB LEVEL 14

Sign-Up: 07/08/07

Posts: 2,975

If I understand correctly, you want flash to not play one line of code, no?
So all you do is in front of that line of code put:
//(code)

BBS Signature

None

El-Presidente

Reply To Post Reply & Quote

Posted at: 6/15/09 10:55 AM

El-Presidente LIGHT LEVEL 27

Sign-Up: 06/02/05

Posts: 5,162

Didn't look at the code itself, but trace everything to make sure that it's getting to the line. It could be that one of your ifs is not working because it's not true.

MY E-PENIS IS BIGGER THAN YOURS
8=================================>
...and this is my fag...

BBS Signature

None

edit-undo

Reply To Post Reply & Quote

Posted at: 6/15/09 10:56 AM

edit-undo LIGHT LEVEL 18

Sign-Up: 01/17/06

Posts: 1,776

No, what he;s saying is that Flash appears to be skipping a line of code.

Try putting

trace("booyah");

immediately after the onEnterFrame line. This way you can see if the code is being skipped or not. If the trace appears when the game is run, then the code is being triggered, but the logic in it is wrong. Try this and let me know what happens.

lolsigtrend
i just wanna fit in :'(

BBS Signature

None

milchreis

Reply To Post Reply & Quote

Posted at: 6/15/09 01:20 PM

milchreis DARK LEVEL 16

Sign-Up: 01/11/08

Posts: 403

your "else if" statement is not making too much sense, if sling is not true, it is probably (if initialized correctly) false. No need for the additional "if"

hint for shortening the code:

if(sling ==true)
is the same as
if(sling)

onEnterFrame Problem:
the onEntter Frame "Event" probably happens, so the function should be called ;D
as you only have if statements, none of them seems to come out as true and so nothing happens, try (as previously proposed) to trace out something, or the variables.

"Even if it's just cynicism that remained to push us ahead, we'll carry on!"


None

seanjames

Reply To Post Reply & Quote

Posted at: 6/15/09 02:38 PM

seanjames EVIL LEVEL 37

Sign-Up: 04/01/03

Posts: 104

Hey ironman, did you get this sorted out?

BBS Signature

None

iamironman

Reply To Post Reply & Quote

Posted at: 6/16/09 09:20 AM

iamironman DARK LEVEL 13

Sign-Up: 08/05/06

Posts: 388

no i havent gotten this fixed yet.

i have put a trace just about every were (and thanks for the code, i never did hear about "trace" before darrrrrr) and im coming to the conclusion that the code is not making it to the onEnterFrame.... so the exact conclusion that i had before. no im not trying to skip i line of code, im trying to PREVENT a line of code from being skipped, or a block of code for that matter.

i have never seen a program skip over the onEnterFrame before so i am at a loss for words, i dont have any other way to explain it. but when it gets to the onEnterFrame, it just skips it! unless im un aware of how functions work (which i dont think i am), this is reallly stuped!

(\_/)
( '.' )
(")(") this is bunny, copy and paste him to your forum signaturse to help him gain world domination


None

GustTheASGuy

Reply To Post Reply & Quote

Posted at: 6/16/09 09:57 AM

GustTheASGuy LIGHT LEVEL 08

Sign-Up: 11/02/05

Posts: 11,326

Be more detailed about what you're expecting to happen. The functions are not going to be executed when that script is run, they're only assigned for the next events to come.

#ngprogramming at irc.freenode.net
haXe | Keel imperative | Spyro! | Thru you


None

asgrunt

Reply To Post Reply & Quote

Posted at: 6/16/09 10:10 AM

asgrunt NEUTRAL LEVEL 01

Sign-Up: 05/26/09

Posts: 164

From what you posted we can't tell what is wrong - since Flash doesn't skip anything. If you take just that code and put a trace("sling: "+sling) into the if and else, you will get a notice if you click with the mouse. But without any click nothing will happen. AS2 doesn't initialize a var if it is not explicitly declared (AS1 did). So your sling is undefined as long as it doesn't get initialized with true or false.


None

iamironman

Reply To Post Reply & Quote

Posted at: 6/17/09 01:32 AM

iamironman DARK LEVEL 13

Sign-Up: 08/05/06

Posts: 388

ok, to clarify.

when i put a trace() command anywhere inside the enter frame (yes outside the IF's) and run my program, nothing happens. i don't get a box, because its a loop it should be tracing at the frame rate... so it should be a mile long of a trace in about 3 seconds, but ZIP! ZILCH! NINE!

thats my question, i know flash doesn't skip lines, i know everything your all telling me, i have been doing this a while too!

getting really old re explaining my problem please read the posts.

(\_/)
( '.' )
(")(") this is bunny, copy and paste him to your forum signaturse to help him gain world domination


None

asgrunt

Reply To Post Reply & Quote

Posted at: 6/17/09 02:30 AM

asgrunt NEUTRAL LEVEL 01

Sign-Up: 05/26/09

Posts: 164

when i put a trace() command anywhere inside the enter frame (yes outside the IF's) and run my program, nothing happens
I guess you don't click. The it happens exactly what I told before: sling is neither true nor false but undefined. In that case the onEnterFrame does ignore your code since everything depens on a true or false value of your vars


Questioning

milchreis

Reply To Post Reply & Quote

Posted at: 6/17/09 09:57 AM

milchreis DARK LEVEL 16

Sign-Up: 01/11/08

Posts: 403

At 6/17/09 01:32 AM, iamironman wrote: getting really old re explaining my problem please read the posts.

don't have such strange problems! =P

I don't really remember as2 very well.
Did you try "_root.onEnterFrame"?

"Even if it's just cynicism that remained to push us ahead, we'll carry on!"


None

atomoxic

Reply To Post Reply & Quote

Posted at: 6/17/09 11:35 AM

atomoxic LIGHT LEVEL 10

Sign-Up: 02/16/09

Posts: 226

By using this in Flash CS4 with AS2 with a trace the onEnterFrame initialises as it should do:

onMouseDown = function () {
	sling = false;
};
onMouseUp = function () {
	cam.stopDrag();
	sling = true;
};
onEnterFrame = function () {
	trace("Initialised!");
	if (!cam.hitTest(ball) && holder == false) {
		cam.stopDrag();
		sling = true;
	}
	if (sling == true) {
		ydiff = _root.ball._y-cam._y+ycamset;
		xdiff = _root.ball._x-cam._x+xcamset;
		cam._x += xdiff*speed;
		cam._y += ydiff*speed;
	} else if (sling == false) {
		cam.startDrag(false);
	}
}

Theres not problem with the code reaching the onEnterFrame with that. Did you put a trace where I did to test it or within one of your if functions?

BBS Signature

None

asgrunt

Reply To Post Reply & Quote

Posted at: 6/17/09 11:48 AM

asgrunt NEUTRAL LEVEL 01

Sign-Up: 05/26/09

Posts: 164

it is not a problem of running the enterFrane - of course that event doesoccur. The problem lies with the code inside that event, to be more precise: all the ifs are wrong as long as the vars are undefined. In as2 they are no longer automatically initialized, they are simply undefined


None

Slipstreamer

Reply To Post Reply & Quote

Posted at: 6/17/09 12:01 PM

Slipstreamer NEUTRAL LEVEL 18

Sign-Up: 12/05/06

Posts: 678

At 6/15/09 09:37 AM, Alpharius120 wrote: If I understand correctly, you want flash to not play one line of code, no?
So all you do is in front of that line of code put:
//(code)

That wouldn't even do anything lol

Slips - A hardass smartass response to ignorance.
yep yep yep.
mhmm.

BBS Signature

None

atomoxic

Reply To Post Reply & Quote

Posted at: 6/17/09 12:07 PM

atomoxic LIGHT LEVEL 10

Sign-Up: 02/16/09

Posts: 226

Using:

// Code here

Would prevent that line of code being used as it would not be published into the swf. Its only useful to do that when debugging and testing code to find where errors are or stop functions you dont want running at that particular stage of development.

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 12:06 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!