Error Message, what does it mean?


does anyone understand what this error message means:

Symbol=A Button, Layer=sub link 1, Frame=2: Line 1: Statement must appear within on handler
but2.onPress = function() {

it comes up when I try to test my movie. This code is applyed to a button which is inside a mc (movie clip).

here is the full code:

//but2 is the button instance name
but2.onPress = function() {
if (_root.currMovie == undefined) {
_root.currMovie = “section3”;
} else if (_root.currMovie != “main”) {
if (_root.container2._currentframe>=_root.container2.midframe) {
_root.currMovie = “section3”;;

Thanks in advance :thumb2: