Why doesn't this simple function work?

Check out this simple attachment. You got your as
my_btn.onRelease = function() {
trace(“It worked”);
}

The Instance Name on the button is my_btn. Ok, why does it work if the as is on the same frame as the button but not if you move the button over a frame. I thought the point of using a function was that you only need to write it once. I don’t want to put this function on every frame where the button is located.

What am I missing here?

The object needs to be loaded before you cana ssign a function to it like that. Simple as that. :slight_smile:

You could have done it like this…

Ok. That makes sense. So as long as the action script comes anywhere on the timeline overlapping the instance name you are good.

In that sense it is a little different than other functions.
thanks…