Forum Topic: Synax Error

(157 views • 12 replies)

This topic is 1 page long.

<< < > >>
Resigned

mariomaster123

Reply To Post Reply & Quote

Posted at: 6/11/08 09:54 PM

mariomaster123 LIGHT LEVEL 09

Sign-Up: 04/27/08

Posts: 134

Sorry about this topic, I just am confused about this:
I have a boolean above my onClipEvent (enterframe){
it looks like this:

varClose: Boolean
onClipEvent (enterframe){
...

why is there an error????

It is ALWAYS peanut butter jelly time...

BBS Signature

None

korded

Reply To Post Reply & Quote

Posted at: 6/11/08 10:03 PM

korded EVIL LEVEL 06

Sign-Up: 02/06/00

Posts: 1,029

If you're placing this action on a movieclip, the variable has to be declared within an onClipEvent function as well, like..

onClipEvent(load) {
var whatever:Boolean;
}

Or, if the action is being placed on a keyframe, you can't use onClipEvents.

Either way, put a space between var and your variable name if you haven't already.


Crying

mariomaster123

Reply To Post Reply & Quote

Posted at: 6/11/08 10:04 PM

mariomaster123 LIGHT LEVEL 09

Sign-Up: 04/27/08

Posts: 134

hmm, but then the things under it repeat in a cycle...

It is ALWAYS peanut butter jelly time...

BBS Signature

None

mariomaster123

Reply To Post Reply & Quote

Posted at: 6/11/08 10:08 PM

mariomaster123 LIGHT LEVEL 09

Sign-Up: 04/27/08

Posts: 134

AND there are even more errors...

It is ALWAYS peanut butter jelly time...

BBS Signature

None

DrkFox

Reply To Post Reply & Quote

Posted at: 6/11/08 10:10 PM

DrkFox EVIL LEVEL 08

Sign-Up: 01/03/08

Posts: 283

At 6/11/08 09:54 PM, mariomaster123 wrote: Sorry about this topic, I just am confused about this:
I have a boolean above my onClipEvent (enterframe){
it looks like this:

varClose: Boolean
onClipEvent (enterframe){
...

why is there an error????

you must declare the boolean

var varname:Boolean = true;


None

mariomaster123

Reply To Post Reply & Quote

Posted at: 6/11/08 10:15 PM

mariomaster123 LIGHT LEVEL 09

Sign-Up: 04/27/08

Posts: 134

ok, there are still more errors. This is my code, maybe there is something wrong with it:

varClose:Boolean
onClipEvent (enterframe) {
distance = 200;
ux = _root.warrior._x;
uy = _root.warrior._y;
ex = _root.boss1._x;
ey = _root.boss1._y;
if (ux-ex<=distance && ux-ex>=-distance) {
if abs(warrior._x-enemy1._x)<50){
if (!Close){
attack = random(4);
switch (attack) {
case 0 :
this.gotoAndStop("boss1attack1");
//attack 1
break;
case 1 :
this.gotoAndStop("boss1attack2");
//attack 2
break;
case 2 :
//...
this.gotoAndStop("boss1attack3");
//attack 3
break;
case 3 :
this.gotoAndStop("boss1attack4");
//attack 4
break;
}
Close = true
}
else Close = false;
// Ainarow = attacks in a row
} else {

if (ux<ex-40) {
this._x -= 2;
this.gotoAndStop("boss1walkleft");
//bossisgoingleft!!!!
}
if (ux>ex+40) {
this._x += 2;
this.gotoAndStop("boss1walkright");
}
}
}

It is ALWAYS peanut butter jelly time...

BBS Signature

None

Swordsbite

Reply To Post Reply & Quote

Posted at: 6/11/08 10:23 PM

Swordsbite NEUTRAL LEVEL 08

Sign-Up: 03/10/08

Posts: 640

At 6/11/08 10:15 PM, mariomaster123 wrote: ok, there are still more errors. This is my code, maybe there is something wrong with it:

varClose:Boolean

Should be on the main timeline, and made like this var Close:Bolean = false or true;

onClipEvent (enterframe) {
distance = 200;
ux = _root.warrior._x;
uy = _root.warrior._y;
ex = _root.boss1._x;
ey = _root.boss1._y;
if (ux-ex<=distance && ux-ex>=-distance) {
if abs(warrior._x-enemy1._x)<50){
if (!Close){
attack = random(4);
switch (attack) {
case 0 :
this.gotoAndStop("boss1attack1");
//attack 1
break;
case 1 :
this.gotoAndStop("boss1attack2");
//attack 2
break;
case 2 :
//...
this.gotoAndStop("boss1attack3");
//attack 3
break;
case 3 :
this.gotoAndStop("boss1attack4");
//attack 4
break;
}
Close = true

Should be Close == true; (= is for setting a value, == is declaring it or whateever)

}
else Close = false;

else Close == false;

// Ainarow = attacks in a row
} else {

if (ux<ex-40) {
this._x -= 2;
this.gotoAndStop("boss1walkleft");
//bossisgoingleft!!!!
}
if (ux>ex+40) {
this._x += 2;
this.gotoAndStop("boss1walkright");
}
}
}

Try all that stuff, theres prob more

Footsteps of zrb || As:Main || As3:Main || Flash Tutorials || PM me for help. ||


Goofy

zrb

Reply To Post Reply & Quote

Posted at: 6/11/08 10:24 PM

zrb LIGHT LEVEL 10

Sign-Up: 08/08/06

Posts: 3,851

varClose:Boolean
onClipEvent (enterframe) {

Your off on a bad start.
Anyways here's the revised version of your code, no errors too:

onClipEvent (enterFrame) {
	var Close:Boolean;
	distance = 200;
	ux = _root.warrior._x;
	uy = _root.warrior._y;
	ex = _root.boss1._x;
	ey = _root.boss1._y;
	if (ux-ex<=distance && ux-ex>=-distance) {
		if (abs(warrior._x-enemy1._x)<50) {
			if (!Close) {
				attack = random(4);
				switch (attack) {
					case 0 :
						this.gotoAndStop("boss1attack1");
						//attack 1
						break;
					case 1 :
						this.gotoAndStop("boss1attack2");
						//attack 2
						break;
					case 2 :
						//...
						this.gotoAndStop("boss1attack3");
						//attack 3
						break;
					case 3 :
						this.gotoAndStop("boss1attack4");
						//attack 4
						break;
				}
				Close = true;
			} else {
				Close = false;
			}// Ainarow = attacks in a row
		} else {

			if (ux<ex-40) {
				this._x -= 2;
				this.gotoAndStop("boss1walkleft");
				//bossisgoingleft!!!!
			}
			if (ux>ex+40) {
				this._x += 2;
				this.gotoAndStop("boss1walkright");
			}
		}
	}
}

I can speak french :3 || As :Main || As3: Main || Animation: Main || Flash Tutorials ||

BBS Signature

None

Swordsbite

Reply To Post Reply & Quote

Posted at: 6/11/08 10:26 PM

Swordsbite NEUTRAL LEVEL 08

Sign-Up: 03/10/08

Posts: 640

love ya ZRB, ur ausome lol

Footsteps of zrb || As:Main || As3:Main || Flash Tutorials || PM me for help. ||


None

mariomaster123

Reply To Post Reply & Quote

Posted at: 6/11/08 10:29 PM

mariomaster123 LIGHT LEVEL 09

Sign-Up: 04/27/08

Posts: 134

lol, ur stuff only makes him what he did before
Essentially, I want him to do one of the four attacks at the certain distance... he is now walking at the certain distance

It is ALWAYS peanut butter jelly time...

BBS Signature

Resigned

zrb

Reply To Post Reply & Quote

Posted at: 6/11/08 10:33 PM

zrb LIGHT LEVEL 10

Sign-Up: 08/08/06

Posts: 3,851

lol, ur stuff only makes him what he did before
Essentially, I want him to do one of the four attacks at the certain distance... he is now walking at the certain distance

Well I didn't really know that since you didn't mention it. I thought all you needed was help with all your errors. Try to figure it out now that there are no errors.

I can speak french :3 || As :Main || As3: Main || Animation: Main || Flash Tutorials ||

BBS Signature

None

mariomaster123

Reply To Post Reply & Quote

Posted at: 6/11/08 10:40 PM

mariomaster123 LIGHT LEVEL 09

Sign-Up: 04/27/08

Posts: 134

ok, well i completly confused now
errors are a problem, but making my enemy do what he has to do is WAY more important, that is the whole goal...

It is ALWAYS peanut butter jelly time...

BBS Signature

Resigned

mariomaster123

Reply To Post Reply & Quote

Posted at: 6/12/08 10:16 PM

mariomaster123 LIGHT LEVEL 09

Sign-Up: 04/27/08

Posts: 134

i think the boolean HAS to be in front for the guy to DO his attack and then reset the flag...

It is ALWAYS peanut butter jelly time...

BBS Signature

All times are Eastern Daylight Time (GMT -4) | Current Time: 07:34 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!