PDA

View Full Version : OnClipEvent handler error msg (flash8)


porpoise
03-14-2007, 08:44 PM
I'm trying to add some controls to an mp3 player into an empty clip on my stage, and the following error occurs:

Line 1: Statement must appear within on/onClipEvent handler
this.onEnterFrame = function () {

The tutorial I'm using explains to create an empty mc (that loops) and place it anywhere on the stage, then add the code.

I've got a bunch of other AS on frame one that may be causing this error, but I'm not sure. Is this common? Let me know if you need to see the main AS.

Thanks for any help!

WhidbeyTomas
03-15-2007, 03:11 AM
First off, you can't depend greatly on the error messages. They are, generally, jut a hint that something is wrong somewhere close to that code. It is hard to tell what your problem is with the limited information you provide. Can you zip the FLA? (You might need to strip out images to keep it small).

porpoise
03-15-2007, 01:57 PM
Thanks for the reply. I was able to troubleshoot the problem. What I did was create an empty mc named "Fred" (it was the only thing i could think of at the time...my brain was fried), and changed the code to:

fred.onEnterFrame = function() {

...and it worked. Is it possible to have too many "this.onEnterFrame" statements in a block of as? Do they compete?

WhidbeyTomas
03-21-2007, 11:54 PM
Actually, I should have given you a better answer. The reason I didn't is that I don't know much about onClipEvent. I tried using it this week and came up with the same error. The deal is, and this is the reason I don't use onClipEvent, this handler is used to attach code to an MC. It is not placed on the timeline, but you just click on the MC where it sits on the stage and then click on the actions panel and enter your code. The trouble is, you can't see any indication that there is code on an MC without clicking on the MC. Most scripters don't use this.

Ideally, code is centralized. It makes managing a movie much simpler. People attach code to several MCs because it helps them associate code with the place it is used. This is great when you are familiar with the file, but it can make a file a bit like a rat maze when you are not familiar with the file. And when I don't use good organization, it doesn't take long to become unfamiliar with my own files!

The best solution (in my opinion) is to either put code on the main timeline (frame1) or to put it in external as files.