PDA

View Full Version : 5006: An Actionscript file can not have more than...


MarionC
03-05-2008, 08:07 PM
Hello all,

I am very puzzled why I am receiving this error. I wanted to experiment with the document class and created just the bare minimum (to test compiling) and received the error:

5006: An Actionscript file can not have more than one externally visible definition: Main, startPlay

I don't have multiple classes defined and Main has been defined as a document class from the property inspector menu.

My code as follows:
myMain.fla:

startPlay();


Main.as file:

package {
import flash.display.MovieClip;
public class Main extends MovieCip{
public function startPlay(){
trace ("started it");
}

}
}


I don't see how I have multiple external definitions. :x I only have one class defined. It seems like the document class cannot have any functions within it with this error and that seems wrong somehow. What am I missing?

Any help is appreciated.
-m

straydog
03-05-2008, 08:28 PM
aren't you missing a listener? Maybe its different when you use an external .as file

MarionC
03-06-2008, 04:21 PM
I figured it out!

Ironically when I typed the code here in this message, I typed the main.as code correctly but incorrectly in the .as file. :p

The function startPlay was OUTSIDE of the the public class main {} and hence, the compiler interpreted this as a 2nd class. doh. I resituated the parenthesis and voila, it's a happy camper. Well hell, I'm a happy camper. :D

Onward to trying to things that will get me stuck (again.) I don't mind being stuck as long it's a new kind of stuck.

-m