Skip to main content
Participant
July 10, 2009
Answered

Trying to do this brick braker tutorial.

  • July 10, 2009
  • 2 replies
  • 882 views

Hi I'm new to Flash and am trying to do this brick braker tutorial on www.tutorialhero.com/click-55897-how_to_creat_a_platform_game_in_as2.php but I can't even get the first line of code to work.

This is the code soposed to be paddle movement using the mouse and then the paddles suposed to stop at the edge of the screen:

onEnterFrame = function() {

     mcPaddle._x = _xmouse - mcPaddle._width*.5;

If(_mouse < mcPaddle._width / 2) {

     mcPaddle._x = 0;

}

if(_xmouse > Stage.width - mcPaddle._width / 2) {

     mcPaddle._x = Stage.width - mcPaddle._width;

}

}

I get an error for the first line saying that Statement must appear within on/onClipEvent handler.

I don't know what this means can anyone help?

This topic has been closed for replies.
Correct answer Ned Murphy

According to the tutorial those pieces of code go in two different places...

Add the following code to the very beginning (line 1) of your code. I like to organize all my variables so that they are all in the same place.

//These variables are needed for moving the ball
var ballXSpeed:Number = 10; //X Speed of the Ball
var ballYSpeed:Number = 10; //Y Speed of the Ball

You can change these values if you want, but this is what I’m going to use. Now, we have to use these variables to make the ball move. We should now add the following code to the onEnterFrame() function:

//MOVING THE BALL
mcBall._x += ballXSpeed;
mcBall._y += ballYSpeed;

The last one is probably why you aren't seeing anything moving.

The tutorial author has provided the source files, so you should be able to refer to those without having to ask anyone where it goes.

I don't know of any game tutorials, so you may have to grin and bear it and try to develop an understanding of the coding and techniques so that you can create your own.  Understanding the code is more important than having the code.

2 replies

Participant
July 11, 2009

Didn't want to creat a hole new thread since I'm stuck on the same tutorial.  This time though it has to do with making the ball move this is the code:

var ballXSpeed : Number = 10;

var ballYSpeed : Numbet = 10;

mcBall._x += ballXSpeed;

mcBall._x += ballYSpeed;

Now the problem is the author of the tutorial did not explain were this code goes. I tried adding it to the circle itself then to the timeline with the other code I created in the first step but the ball doesn't move anywere.  And judgeing by the comments on each page of this web tutorial there seems to be a pattern of one crutial bit of info missing each step so does anyone know of a tutorial site similar to how this ones set with the mind set of teaching flash game creation starting from simple games to complex like this site but without the constent lappses of info?  If not then I'll have to warren you this thread most likely will grow plus looking at the comments for the other tutorials I will most likely hit a rut when working though them.

Any help to those two questions would be appeseated.

Ned Murphy
Ned MurphyCorrect answer
Legend
July 11, 2009

According to the tutorial those pieces of code go in two different places...

Add the following code to the very beginning (line 1) of your code. I like to organize all my variables so that they are all in the same place.

//These variables are needed for moving the ball
var ballXSpeed:Number = 10; //X Speed of the Ball
var ballYSpeed:Number = 10; //Y Speed of the Ball

You can change these values if you want, but this is what I’m going to use. Now, we have to use these variables to make the ball move. We should now add the following code to the onEnterFrame() function:

//MOVING THE BALL
mcBall._x += ballXSpeed;
mcBall._y += ballYSpeed;

The last one is probably why you aren't seeing anything moving.

The tutorial author has provided the source files, so you should be able to refer to those without having to ask anyone where it goes.

I don't know of any game tutorials, so you may have to grin and bear it and try to develop an understanding of the coding and techniques so that you can create your own.  Understanding the code is more important than having the code.

Participant
July 11, 2009

Thanks again Ned now that I reread it after taking a breather I had to smack my self for not looking at the source code.  I think I gona take a break from this to finish a project that I thinks stressin me out causing me to skip over these steps without thinking.  Hopefully then I wont fill the blog with such noob questions.

Thanks again Ned.

Ned Murphy
Legend
July 10, 2009

Put the code you have on the timeline, not on the movieclip, and it should work (though you have a typo....that first If should be if )

Participant
July 10, 2009

Thanks for the help that did it.

Ned Murphy
Legend
July 10, 2009

You're welcome