06.19.07

Flash CS3 / Flex 2 AS3 Error #1078

Posted in errors, Flash, Flex at 5:43 pm by Curtis J. Morley

Error #1078: Label must be a simple identifier.

Description:
The main reason you will get this ActionScript error comes because of mistyping a colon. You can get AS3 Error 1078 by putting a a colon at the end of a line instead of a semicolon. You can get it by trying to 'Type' an object without the 'var' keyword, and my personal favorite - If you are in Flash writing a Class and hit the quick keys esc >> t >> r to get a trace(); statement you will get trace():void; instead.

Fix 1:
This error can be resolved by correctly typing a semicolon.

Bad Code1

myText.border = false:

Good Code1 :

myText.border = false;

Fix 2:
This can be resolved by using the keyword var. (The bad code example here is really bad code)

Bad Code 2:

this.box:MovieClip = new MovieClip();

Good Code 2:

var box:MovieClip = new MovieClip();

Fix 3:
Delete the silly extra stuff that Flash puts in there for you. If you have the bad code as shown below you will most likely get another error like 1083. Just fix the first and the second will also be resolved.

Bad Code 3:

trace():void

Good Code 3:

trace();

And that is how you solve ActionScript Error #1078

Happy Flashing

24 Comments »

  1. Mihai said,

    July 13, 2007 at 1:29 pm

    I also got the error because I wrote this (without realising, of course):

    this._box:VBox = new VBox();

    …strange that the error isn’t a bit more descriptive of what the problem actually is.

  2. Curtis J. Morley said,

    July 13, 2007 at 9:49 pm

    Mihai,
    Thanks for the comment. This is another good example of when you will get this ActionScript Compile error. It is due to scope.

    Bad Code:
    this.box:MovieClip = new MovieClip();

    Good Code:
    var box:MovieClip = new MovieClip();

    Hope this helps and Happy Flashing
    Curtis J. Morley

  3. curtismorley.com » Added new info to ActionScript Error #1078 said,

    August 22, 2007 at 7:48 pm

    […] ActionScript 3 Error #1078 […]

  4. Andrew said,

    May 27, 2008 at 11:31 am

    Thanks, that solved my problem, what a mysterious error πŸ™‚

  5. curtismorley.com » Search Engine Optimization Example said,

    June 2, 2008 at 4:50 pm

    […] AS3 Error 1083 – #1,2 hit on Google […]

  6. austin said,

    June 24, 2008 at 7:22 pm

    This has not helped me yet. I learned flash in actionscript 1.0 so naturally i’m getting all kinds of errors. This is my latest one. Error 1078 every time I just try to reference a movie clip. What am I doing wrong? Here is some examples of code that produced error:

    (Actually, as I just went to go copy the code, I found that I did put in a colon! AHHH.) Thank you!

    hahaha…

  7. Brart said,

    June 25, 2008 at 6:30 am

    It also give this error if:

    var box:Menu1 = Menu1;
    addChild(box):

    Good code:

    var box:Menu1 = Menu1;
    addChild(box);

    THe difference:

    : -> ;

    Brart

  8. Curtis J. Morley said,

    June 26, 2008 at 12:41 pm

    Austin and Brart,

    Glad that this helped. The semicolon is often hard to recognize and therefore difficult to see when troubleshooting. Good example Brart.

    Thanks,
    Curtis J. Morley

  9. tim said,

    October 3, 2008 at 12:13 am

    I’m getting the error when i’m trying to TYPE a variable within an object or array:

    var myVar:Array = new Array();
    myVar[‘aNumber’]:Number = 0;

    Throws: 1078: Label must be a simple identifier.

    Any ideas why?

    thanks,

    Tim

  10. Leon Stafford said,

    October 15, 2008 at 4:54 am

    Cheers,

    stupid semi-colon mistake, thanks to this page and a quick Google search, am back to work πŸ˜›

  11. Mike said,

    October 28, 2008 at 10:55 am

    I’ve still got the 1078 error.
    bad code:
    function addParticle2(e.Event)

    it tells me that “Label must be a simple identifier”
    I do not not know why it does this because it checks out with:
    function addParticle(e.Event)
    and I’ve created both Particle and Particle two as movie clips, exporting to action script and in first name. I’ve named 1 “dot” and the other “dot2”. I also appropriately defined dot and dot2 as variables. perhaps maybe you can tell me whats wrong with the code.

    thanks,
    Mike

  12. CyberDave said,

    November 20, 2008 at 7:22 am

    u rock dude….. i just had the same trouble
    DATAGRID_DebitorenAuswahl.y = TEXTINPUT_Debitor_von.y + TEXTINPUT_Debitor_von.height:

    just won’t compile with strange message…

    ur blog saved our souls.

    greetings from outa space

  13. Dylan said,

    December 19, 2008 at 6:00 am

    Thanks, this helped me find my problem. My issue was that I had mistyped a function declaration like this:

    // correctly defined previous function…

    addEventListener(…):void; // I accidentally put void here instead of the return type in the next function signature

    } // end previous function

    private function nextFunction() { // This line was missing the return type three lines above
    // code
    }

    When I moved my misplaced code the 1078 error went away.

  14. johnCitizen said,

    April 21, 2009 at 12:45 am

    I was also getting “1078: Label must be a simple identifier.

  15. Ryan said,

    June 10, 2009 at 5:51 pm

    Hey Curtis awesome helpful blog! I have an error I hope you can help me with. I have watched many tutorials and I’m starting to get the hang of AS 3 but I’m getting an error 1078 that I can’t explain. I would be real grateful if you took a look. I have a variable named splat_mc which is a movieclip. I have a function called splatter. I’m not sure what I’m doing wrong. Any help would be appreciated thanks!!!

    splat_mc.addEventListener(MouseEvent.RIGHT_CLICK, splatter):void

  16. Joe said,

    June 12, 2009 at 11:52 am

    @Ryan: take the “:void” off the end of that line and replace it with a semicolon… you should have the declaration of the event listener like this:

    splat_mc.addEventListener(MouseEvent.RIGHT_CLICK, splatter);

    then the function definition like this:

    function splatter(evt:MouseEvent):void
    {
    // event handler stuff here
    }

  17. Alex said,

    June 28, 2009 at 10:36 am

    Good post solved my problem

  18. Svl said,

    July 8, 2009 at 6:16 am

    Thank you, Curtis!
    I also had colon at the end and lost some time before finding your article.

  19. Phil said,

    July 16, 2009 at 3:07 pm

    Great post – thanks!

  20. mok said,

    September 1, 2009 at 7:01 am

    Here’s one:

    Bad:
    private getObject():Object
    {
    return
    {
    attrib1:objA.stuff,
    attrib2:objB.stuff
    };
    }

    Good:
    private getObject():Object
    {
    var obj:Object =
    {
    attrib1:objA.stuff,
    attrib2:objB.stuff
    };
    return obj;
    }

  21. sivakami said,

    November 13, 2009 at 6:27 am

    Thanks for posting this, it saved my time.

  22. MrSteel said,

    February 14, 2010 at 7:26 am

    good that you come out first for this search πŸ™‚

    thanks

  23. robert said,

    February 27, 2010 at 9:46 am

    I can’t imagine life without google and posts like these.

    Thanks a lot!

  24. sebomoto said,

    September 28, 2010 at 11:20 am

    thanks very much, i had typed the colon…

    sebastian

Leave a Comment