Tutorial: Create a Game Like Winter Bells in AS3 – Part 5

Written By MrSun at 8:05 am - Wednesday, January 07th, 2009
Categories: Flash

Step 5: Finishing Touches

This part of tutorial is where we add some bug fixes and special effects. Let’s get started.

The next bug we need to fix occurs after the mcFinalStats is shown on the screen. Whenever you click anywhere, mcMain can still jump. We can fix this no problem. Add an && !gameOver to the if statement in the mcBg‘s click function. That’s all we need.

Now, we can add some special effects. The first one, of course, is going to be a background. First, move where we created the bellHolder to the top of the code. Next, add this code right below it:

var bgHolder:MovieClip = new MovieClip();//create a MovieClip to hold all bg shapes
bellHolder.addChild(bgHolder);//add it to the bellHolder to move with everything

Then, add this code to the eFrame() function.

//creating a new shape
var mcBg:Shape = new Shape(); 
//making random dimensions (only ranges from 1-3 px)
var dimensions:int = int(Math.random()*3)+1;
/add color to the shape
mcBg.graphics.beginFill(0x333333/*The color for shape*/,1/*The alpha for the shape*/);
//turning the shape into a square
//change the coordinates of the particle
mcBg.x = int(Math.random()*stage.stageWidth);
mcBg.y = bellTop-bgHolder.y;
//adding the particle to bgHolder

bgHolder.y += 2;//make bg move downward

Now, we notice that the background is actually in front of the main character. Do not fret, simply add this code to the bottom of everything:


Well, I guess that pretty much finished up everything. I hoped you learned much from my tutorial!

The Final Product

Source Files (zipped)



Nice tutorial.But if you fly higher and score more and then miss a “box” you don’t get back to the “ground” and now “stats box” appears…a bug ?


hii, i learned a lot from your tutorial and i appreciate your efforts.I would like to draw your attention to 1 bug which u might not have gone thru that is when the main ball reaches to a maximum height and when it falls down it stays in the air does not fall on stage


Again, Nice tutorial, but the bug where you get so high, and then miss a block, you do not fall to the ground, you merely fall into nothingness, can you find a solution?


Very nice tutorial but the bugg is is weird. i cant fix it.


Very nice tutorial! I messed my code up 🙁 Can you please send the .fla to me? I get error when I open your. The docfile has been corrupted


@mathias You can find the source files (zipped just below the tests of the game.


Also my suggestion about the falling of the stage is this: As you begin to fall to the ground in the output and compiler errors i get this:

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at Bell/eFrame()

Im guessing this is the problem, but as im not to experienced with as3 im having trouble fixing it. I guess it is just an argument error.


I also like this tutorial but, I’m having the same problem where sometimes when the game should end it doesn’t and I have to open a new swf to get it to work. Sometimes this doesn’t work though. I just tried it a bunch of times and it seemed like the first time it didn’t work then it would work. I think it might be happening randomly


hey this was awsom but the tutorials need a little more discription


the bug where you just keep falling is kinda serious, does anyone know how to ix it, because im starting to get used to this but cant quite fix the problem


to fix the problem, simple replace

if(mcMain.y >= 275 && totalHeight >= 275){
bellHolder.y -= jumpSpeed;
bellTop += jumpSpeed;
mcMain.y = 275;


if(mcMain.y >= 10000000 && totalHeight >= 10000000){
bellHolder.y -= jumpSpeed;
bellTop += jumpSpeed;
mcMain.y = 275;




how to you get the game to work? I cant get the bells to appear even though I put the code