Archive for January, 2011

Calling Button Functions from Elsewhere AS3

Usually when you set up a button listener in actionscript 3 it listens for a mouse event and then fires a function. That functions needs to have the mouse event set as a parameter like this book now buttom function:

bookNow.addEventListener(MouseEvent.MOUSE_DOWN,setupBooking);

function setupBooking(event:MouseEvent){

//this is where the functions methods are written

}

The problem is that if I want to call that function from some other place in my code, like from within another function, ie.

setupBooking();

the error fires saying “expecting 1 argument but it received 0.”

The way around this is to declare the argument as null in the function definition, like this:

function setupBooking(event:MouseEvent=null){

}

then we can call it with or without an argument.

Protected: Slattery Helicopters Website Rebuild

This post is password protected. To view it please enter your password below:

Protected: Bali At The Bay – Website Rebuild Proposal

This post is password protected. To view it please enter your password below:

Protected: RidgeView New Website Proposal

This post is password protected. To view it please enter your password below:

Return top