expecting rightbrace

29 posts

Flag Post

doesn’t matter

 
Flag Post

After the addChild (newGoldBar); there should be a } instead of a {

 
Flag Post

Actually, unless I am counting wrong replacing the { with a } would leave him with uneven brackets. The { is excessive.

 
Flag Post

I think you are counting wrong, but the fault is still the OP’s because his indent for the closing brace of onTick is screwed up.

So is the indent of the for each line, for that matter. Not to mention the extraneous blank lines. And the extraneous braces. Gosh, don’t people clean up their code anymore?

 
Flag Post
Originally posted by Drakim:

Actually, unless I am counting wrong replacing the { with a } would leave him with uneven brackets. The { is excessive.

I think you’re counting wrong

package  { //1
	
	import flash.display.MovieClip;
	import flash.utils.Timer;
	import flash.events.TimerEvent;
	
	public class MainGame extends MovieClip { //2
		
		public var army:Array;
		public var goldBar:GoldBar;
		public var gameTimer:Timer;

		public function MainGame()
		{ //3
			army = new Array();
			
			gameTimer = new Timer(25);
			gameTimer.addEventListener(TimerEvent.TIMER, onTick);
			gameTimer.start();
			
		} //2 (close constructor)
		
		public function onTick(e:TimerEvent):void
		{//3
			if( Math.random () < 0.08 )
			{//4
				var randomX:Number = Math.random()*550;
				var newGoldBar:GoldBar = new GoldBar( randomX , -20 );
				army.push(newGoldBar);
				addChild (newGoldBar);
			{//Should close the if statement. 3
				
				for each (var goldBar:GoldBar in Army)
				{ //4
					goldBar.moveDown();
				} //3 (close for each)
			}//2 (close function)

	}//1 (close class)
	
}//0 (close package)

Plus, it makes no sense to put that bucle into the if.

 
Flag Post

This is why you should always make sure your indentation is correct, and matches what you are trying to do. Then it’s easy to see when a brace is missing or out of position, because it doesn’t match the indentation, and it’s easy to see when you’ve completely screwed up, because the indentation doesn’t come back to level 0 at the end.

 
Flag Post

dosen’t matter

 
Flag Post
Originally posted by AlexanderC4:

Sorry I just find it really confusing. I just changed it and it worked but I now have the following error

C:\Users\Alex The Best\Desktop\Golden Catch\Classes\GoldBar.as, Line 12 1046: Type was not found or was not a compile-time constant: TimerEvent.

1. We don’t have the code to that class.
2. It’s pretty obvious what’s happening in that error, can’t you do at least a little research before asking others?

 
Flag Post

Fixed all but one. I can’t figure this one out

package  {
	
	import flash.display.MovieClip;
	import flash.utils.Timer;
	import flash.events.TimerEvent;
	
	public class MainGame extends MovieClip {
		
		public var army:Array;
		public var goldBar:GoldBar;
		public var gameTimer:Timer;

		public function MainGame()
		{
			army = new Array();
			
			gameTimer = new Timer(25);
			gameTimer.addEventListener(TimerEvent.TIMER, onTick);
			gameTimer.start();
			
		}
		
		public function onTick(event:TimerEvent):void
		{
			if( Math.random () < 0.08 )
			{
				var randomX:Number = Math.random()*550;
				var newGoldBar:GoldBar = new GoldBar( randomX , -20 );
				army.push(newGoldBar);
				addChild (newGoldBar);
			}
				
				for each (var goldBar:GoldBar in army)
				{
					goldBar.moveDown();
				}
			}

	}
	
}

C:\Users\Alex The Best\Desktop\Golden Catch\Classes\MainGame.as, Line 28 1137: Incorrect number of arguments. Expected no more than 0.

 
Flag Post

If line 28 is this: var newGoldBar:GoldBar = new GoldBar( randomX , -20 ); Then the error is because the GoldBar class constructor does not expect you to pass arguments.

 
Flag Post

And I fix that how?

 
Flag Post
Originally posted by AlexanderC4:

And I fix that how?

In the GoldBar class:


public function GoldBar (argument1:Number, argument2:Number)
[…]

These are really basic things.

 
Flag Post
package  {
	
	import flash.display.MovieClip;
	import flash.events.Event;
	
	public class GoldBar extends MovieClip {

		public function GoldBar() 
		{
			
		}
		
		public function moveDown(randomX:Number):void
		{
			y = y + 2;
		}

	}
	
}
 
Flag Post
Originally posted by AlexanderC4:

package {

import flash.display.MovieClip;
import flash.events.Event;

public class GoldBar extends MovieClip {

public function GoldBar()
{

}

public function moveDown(randomX:Number):void
{
y = y + 2;
}

}

}

I already told you how to solve it, just add the arguments in the class constructor.

And BTW, why do you pass an argument in the moveDown function if you are not going to use it? And in the last code you posted you are not passing any arguments too.

 
Flag Post
package  {
	
	import flash.display.MovieClip;
	import flash.events.Event;
	
	public class GoldBar extends MovieClip {

		public function GoldBar(x:Number, y:Number) 
		{
			this.x = x;
			this.y = y;
		}
		
		public function moveDown():void
		{
			y = y + 2;
		}

	}
	
}

Also:

		public function MainGame()
		{
			army = new Array();
			
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
			
		}
		
		public function onEnterFrame(event:Event):void
		{
			if( Math.random () < 0.08 )
			{
			//etc.
 
Flag Post

still not working

package  {
	
	import flash.display.MovieClip;
	
	public class GoldBar extends MovieClip {
		
		public var xSpeed:Number;
		public var ySpeed:Number;

		public function GoldBar(randomX:Number, startX:Number, startY:Number) 
		{
			
			x = startX;
			y = startY;
			
			xSpeed = 0.
			ySpeed = 3.
		}
		
		public function moveDown():void
		{
			y = y + ySpeed;
		}

	}
	
}
>/pre>
got same error
 
Flag Post

You didn’t get the same error, technically. Now it’s complaining that you’re passing 2 arguments when it’s expecting 3, not 0 as before. What it shows is that you still haven’t grasped the basic concept of function parameters.

You can’t keep going on like this. You need to get yourself a textbook on AS3 and use it or check yourself into a beginner’s programming class, or something. But you can’t keep on asking people to do your basic debugging for you. Especially since you are visibly not learning anything from us giving you the answers.

And please stop defacing your own posts after you get your answers. You’re not hiding your ignorance, you’re just making the thread harder to follow for new readers.

 
Flag Post
Originally posted by Ace_Blue:
But you can’t keep on asking people to do your basic debugging for you. Especially since you are visibly not learning anything from us giving you the answers.

And please stop defacing your own posts after you get your answers. You’re not hiding your ignorance, you’re just making the thread harder to follow for new readers.

Of course, if anyone that replied had taken the time to explain what was wrong, and why, he might have the chance to understand it for himself instead of having to come back every time there’s a new problem. Instead, there’s a few blocks of code with no real explanation, a few people complaining about how he “should” format his code, and a few people going on about how “obvious” or “easy” the problem is.

You guys always wonder why people in this board don’t like learning AS3, and voila, here’s why, any time someone comes along that’s trying to learn it, you’d rather be condescending about what they don’t know, than help them learn anything new.

 
Flag Post
Originally posted by saybox:
Originally posted by Ace_Blue:
But you can’t keep on asking people to do your basic debugging for you. Especially since you are visibly not learning anything from us giving you the answers.

And please stop defacing your own posts after you get your answers. You’re not hiding your ignorance, you’re just making the thread harder to follow for new readers.

Of course, if anyone that replied had taken the time to explain what was wrong, and why, he might have the chance to understand it for himself instead of having to come back every time there’s a new problem. Instead, there’s a few blocks of code with no real explanation, a few people complaining about how he “should” format his code, and a few people going on about how “obvious” or “easy” the problem is.

You guys always wonder why people in this board don’t like learning AS3, and voila, here’s why, any time someone comes along that’s trying to learn it, you’d rather be condescending about what they don’t know, than help them learn anything new.

Ace_Bule simply pointed out that he basically got the same error from above. That meant the OP had not really investigated further on his mistake, and therefore had not really learned anything new. He simply expected to have a ‘done’ code he could copy and paste for the sake of it. That IMO, is wrong. You need people to point you in the right direction, but you can’t expect them to code for you.

And for one thing I actually like Ace_Blue’s comments, telling him to use a book or take a programming class. That way, the OP would at least be able to learn these basic things.

And the OP keeps removing his posts. That’s BM, since someone who is having the same problem might have been able to use it.

 
Flag Post
Originally posted by saybox:

Of course, if anyone that replied had taken the time to explain what was wrong, and why

Oh yes, if only!

After question 1:
Sumgato: “After the addChild (newGoldBar); there should be a } instead of a {” (What was wrong.)
BobJanova: “This is why you should always make sure your indentation is correct, and matches what you are trying to do. Then it’s easy to see when a brace is missing or out of position, because it doesn’t match the indentation, and it’s easy to see when you’ve completely screwed up, because the indentation doesn’t come back to level 0 at the end.” (Why it was wrong and how to prevent this problem from occuring in the future.)

After question 2:
No solution. OP figured it out on his own in less than an hour.

After question 3:
Sumgato: “If line 28 is this: var newGoldBar:GoldBar = new GoldBar( randomX , -20 ); Then the error is because the GoldBar class constructor does not expect you to pass arguments.” (What is wrong, and why)
The OP then asks for a pre-chewed solution: “And I fix that how?” (I’m counting it as question 4.)
Sumgato gives him one. Others follow.

After question 5:
Ace_Blue: “You didn’t get the same error, technically. Now it’s complaining that you’re passing 2 arguments when it’s expecting 3, not 0 as before.” (What’s wrong, and why.)

All that to say, I strongly dispute your assertion that nobody “that replied had taken the time to explain what was wrong, and why”. We did. The OP is not making a bona fide effort to solve his own problem before posting. It’s not condescension, it’s an observation.

Recommending that the OP “get […] a textbook on AS3” or take “a beginner’s programming class” is not condescending either, BTW. There is no shame in not knowing something, as long as there is a willingness to learn. I’m offering options for the OP to learn more effectively.

At least “us guys” are offering help and giving solutions, we could just be making snide comments from the sidelines about how unhelpful other people are being…

 
Flag Post

Yeah, okay, now take a look at the replies you conveniently didn’t quote….. “it’s pretty obvious”, “can’t you do a little research”, “the fault is the OP’s”, “Gosh, don’t people clean up their code anymore”, “these are really basic things”, “you haven’t grasped the basic concept”, “you’re not hiding your ignorance”.

It’s not really a surprise the OP removes his posts when you talk to him like that, it’s embarrassing to have everyone tell you stuff like that.

Also, when someone asks me how to fix something, I don’t interpret it as them asking me to do the work for them, I tell them how to fix it. It’s your own choice if you decide it means they want you to write their code… it may just be that he doesn’t understand what some of the programming jargon means. Sumgato’s post (the only one offering some explanation) doesn’t explain why it’s incorrect, or how to fix it; of course he’s going to ask how if he still doesn’t understand. Maybe he just didn’t know what was meant by ‘arguments’… it might be basic, but that doesn’t mean he magically understands the term if nobody ever mentioned it before.

And yes, I would happily help if I spoke AS3. Instead, I read the AS3 beginner threads to pick some of it up myself. You can sometimes find me offering lengthy AS2 explanations in threads, since that’s a language I somewhat know.

 
Flag Post

Let’s try to explain…

Alexander, you know what’s a function, right? If you don’t, check this
When you write new GoldBar(); you’re creating a new GoldBar. When a new GoldBar (and every object) is created, it runs the constructor function (the constructor function is the function with the same name as the class).
It’s called ‘constructor’ because there is usually the code needed to “setup” the class. (Example: In your MainGame constructor you create a new array to hold the bars and make a new timer and start listening to it) Well, like in every other function, you can pass arguments (also called parameters).
In your code, when you create a new GoldBar, you pass two arguments: randomX and -20. Then you get an error because the constructor function of GoldBar does not expect two arguments. I hope now you can solve it by yourself. :)
And don’t worry, starting on this is hard.

 
Flag Post

This is exactly the reason I comment my right brackets

}//if (this condition is met)

}//end function doThisNOW()!

}//class
}//package

doing this makes debugging your code easier as it can sniff out the odd { or } you put in or forgot to take out.

 
Flag Post

I know quite alot, basic functions arrays, event listeners how to use classes but some of the syntax and how to format pieces of code really confuse me. Sorry if I really have angered some of you but I can’t help it.

PS- I knew I was too good at this game developer buisness oh and

thanks sumGato for explaining it to me WELL and saybox for describing my situation well

 
Flag Post
Originally posted by FlashGrenade:

This is exactly the reason I comment my right brackets

}//if (this condition is met)

}//end function doThisNOW()!

}//class
}//package

doing this makes debugging your code easier as it can sniff out the odd { or } you put in or forgot to take out.

With clear indenting that’s not necesary at all.

Originally posted by AlexanderC4:

I know quite alot, basic functions arrays, event listeners how to use classes but some of the syntax and how to format pieces of code really confuse me. Sorry if I really have angered some of you but I can’t help it.

PS- I knew I was too good at this game developer buisness oh and

thanks sumGato for explaining it to me WELL and saybox for describing my situation well


You’re welcome.