Hello!
I have Adobe Flash CS6 and I'm starting to use AS3.0.
I'm doing a simple Breakout style game (Only one level). This is the source code for AS3.0:

import flash.events.KeyboardEvent;
import flash.events.Event;

//Paddle motion flags
var moveLeft:Boolean=false;
var moveRight:Boolean=false;

var ballXSpeed:Number=8; //Horizontal ball speed.
var ballYSpeed:Number=8; //Ball vertical speed.

var vector:Vector.<brick> = new Vector.<brick>();

//Calls createBricks function (To create the bricks).
createBricks();

//Event listeners for keys states
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);

stage.addEventListener(Event.ENTER_FRAME, movePaddle);

//Adds an event listener to the ball to call the motion function.
ball.addEventListener(Event.ENTER_FRAME, moveBall);

//Function keyPressed:
//Checks if arrow keys LEFT and Right are pressed and turn the motion paddle
//flags to true. It returns a void value.
function keyPressed(key:KeyboardEvent):void
{
if(key.keyCode==Keyboard.LEFT)
{
moveLeft=true;
}
if(key.keyCode==Keyboard.RIGHT)
{
moveRight=true;
}

}

//Function keyReleased:
//Opposite actions... It returns a void value too.

function keyReleased(key:KeyboardEvent):void
{
if(key.keyCode==Keyboard.LEFT)
{
moveLeft=false;
}
if(key.keyCode==Keyboard.RIGHT)
{
moveRight=false;
}

}

//Function movePaddle:
//Checks if the motion flags of the paddle are "true" and moves the paddle
//in the correct directions. It returns a void value. It's called by the
//stage event listener ENTER_FRAME.
function movePaddle(e:Event):void
{
if(moveLeft)
{
paddle.x-=15;
}
if(moveRight)
{
paddle.x+=15;
}

//Limits stage edges...
if(paddle.x<=0)
{
paddle.x=0;
}

if(paddle.x>=stage.stageWidth-paddle.width)
{
paddle.x=stage.stageWidth-paddle.width;
}

}

//Function moveBall:
//Sets and controls the ball motion. It returns a void value.
function moveBall(e:Event):void
{
ball.x+=ballXSpeed; //Horizontal initial motion
ball.y+=ballYSpeed; //Vertical initial motion

//Checks stage edges and makes the ball to bounce off edges
if(ball.x<=0)
{
ballXSpeed*=-1;
}
if(ball.x>=stage.stageWidth-ball.width)
{
ballXSpeed*=-1;
}
if(ball.y<=0)
{
ballYSpeed*=-1;
}

//Makes the ball to bounce off the paddle (Calls a custom function!)
if(ball.hitTestObject(paddle))
{
bounceAgainstPaddle();
}

for(var i:int=0; i<vector.length; i++)
{
if(ball.hitTestObject(vector[i]))
{
stage.removeChild(vector[i]);
vector.splice(i,1);
ballYSpeed*=-1;
}
}

}

//Function bounceAgainstPaddle:
//Makes the ball to bounce off the paddle correctly.
//It returns a void value.
function bounceAgainstPaddle():void
{
var ballPosition:Number=ball.x-paddle.x;
var hitPercent:Number=(ballPosition /(paddle.width-ball.width))-.5;
ballXSpeed=hitPercent*10;
ballYSpeed*=-1;
}

//Function createBricks:
//Creates the bricks on screen. It returns a void value.
function createBricks():void
{
for(var i:int=0; i<6; i++)
{
for(var j:int=0; j<11; j++)
{
var newBrick:brick = new brick();
newBrick.x=i*57+30;
newBrick.y=j*25+30;
vector.unshift(newBrick)
stage.addChild(vector[0]);
}

}

}



I want to know:
a)- How to check if the player destroyed all the bricks in order to win the game?. I want to do it: If the player breaks all bricks on screen, a congratulation screen will appear.
b)- How to restart the game when player lets the ball fall?. I have to ckeck if(ball.y>=stage.stageHeight), but I don't know what actions have I to put in order to restart all the game.
Please, help me. Thanks! - Nicolás