So I have a button on which I create an instance of a symbol,
I'd like to have a listener for the new symbol but I get a reference error because it compiles the listener before I get to create the instance.
What do I do?

button1.addEventListener(MouseEvent.CLICK, test);
function test(e:MouseEvent):void
{
var ball:Ball = new Ball();
addChild(ball);
}

ball.addEventListener(MouseEvent.CLICK, test2);
function test2(e:MouseEvent):void
{
trace("test");
}