AS3 1084 Syntax Error

  • Started
  • Last post
  • 9 Responses
  • CyBrain

    This is the code for my .as file. I get a crazy error three times for each of the lines that start "private function..."

    package {
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import caurina.transitions.*;
    import caurina.transitions.properties.C...
    ColorShortcuts.init();
    public class mainBtn extends MovieClip {
    public var theDuration:Number = 2.0;
    public function mainBtn() {
    trace("hi");
    this.addEventListener(MouseEvent... mainRollOver);
    this.addEventListener(MouseEvent... mainRollOut);
    this.addEventListener(MouseEvent... mainClick);
    }
    private function mainRollOver(event.MouseEvent):v... {
    Tweener.addTween(this, {_color:0xFFF200, time:theDuration, transition:"easeOutQuart"});
    }
    private function mainRollOut(event.MouseEvent):vo... {
    Tweener.addTween(this, {_color:0xFFFFFF, time:theDuration, transition:"easeInQuart"});
    }
    private function mainClick(event.MouseEvent):void {
    trace("mainBtn click");
    }
    }
    }

    and my error is "1084 Syntax Error: expecting rightparen before dot". This seems like very straightforward code to me, but I'm very bad with AS3. Any help with this would be greatly appreciated. Thanks in advance.

  • acescence0

    if we could actually see it we might be able to help

    http://pastebin.com/

  • tommyo0

    "event:MouseEvent" not "event.MouseEvent" would be my first guess. :)

    • Yes that was it. <hangs head in noob shame> I had a life in AS2 once.CyBrain
    • haha no worries. It'll all sink in, and then you'll go back to an AS2 project and say 'WTF?!?!?!'tommyo
    • I am so far from that stage. Right now, I wish I could go back to AS2.CyBrain
  • CyBrain0

    Yikes, next problem.

    Here's the newly corrected code (only put in the : instead of . as described above)

    package {
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import caurina.transitions.*;
    import caurina.transitions.properties.C...
    ColorShortcuts.init();
    public class mainBtn extends MovieClip {
    public var theDuration:Number = 2.0;
    public function mainBtn() {
    trace("hi");
    this.addEventListener(MouseEvent... mainRollOver);
    this.addEventListener(MouseEvent... mainRollOut);
    this.addEventListener(MouseEvent... mainClick);
    }
    private function mainRollOver(event:MouseEvent):v... {
    Tweener.addTween(this, {_color:0xFFF200, time:theDuration, transition:"easeOutQuart"});
    }
    private function mainRollOut(event:MouseEvent):vo... {
    Tweener.addTween(this, {_color:0xFFFFFF, time:theDuration, transition:"easeInQuart"});
    }
    private function mainClick(event:MouseEvent):void {
    trace("mainBtn click");
    }
    }
    }

    Now I get the error:
    "1046 Type was not found or was not a compile time constant"

    There isn't one mention of textField in that whole .as file. What gives?

  • CyBrain0

    Never mind. I had to import flash.text.TextField;
    because I had dynamic text fields in the buttons in my fla.

    http://curtismorley.com/2007/06/…

    The curtis guy seems to have a lot of answers.

    • I knew I would run into these errors but I'm trying to write classes in separate .as files like grown folk.CyBrain
  • maximillion_0

    instead of import flash.text.TextField;

    you can use

    import flash.text.*;

    which imports all parts of that package - can help with some of the pain your having

    • thanks. got to remember the friendly asterisk.CyBrain
  • tommyo0

    ^^ Kinda sloppy though to do that, it'll import EVERYTHING inside of flash.text instead of just the classes you need. If I could recommend using Flex Builder, it'll add the imports for you. Adobe is actually renaming Flex Builder to Flash Builder. It takes a little getting used to, but it's soooo much more friendly for AS development than the Flash IDE. The beta for Flash Builder 4 is up on http://labs.adobe.com/

  • CyBrain0

    I was wondering what Flash Builder was. I was getting scared that I was going to need to learn yet another realm of scripto-masochism.

  • tommyo0

    Haha yeah, it'll be confusing at first, but I swear to you that it's a damn good AS editor. Very nice when you have a bunch of .as files. You can export swf's directly now too. It also has a great feature where it continuously checks your code every time you save a file, and alerts you to any syntax errors. This feature is especially helpful while you're learning AS3 since as soon as you save, it let's you know about the problem and what you just wrote is still fresh in your head. I pretty much only use Flash to put together UI elements now, and export them as swc files. Everything else I do with Flex Builder, now named Flash Builder. Good stuff and good luck.

  • Pupsipu0

    seriously, you have to use Flex/Flash Builder or FDT. It's crazy not to.

    I tried out TextMate with AS3 Bundle, FlashDevelop (which is ok) but mostly used to code in Flash because the syntax highlighting made me comfortable psychologically. Flex Builder is missing some of the syntax highlighting, not sure if Flash Builder will add it, but screw that.

    I used to waste so much time compiling, seeing errors, recompiling, not being sure where the errors were, making silly little mistakes, spelling things wrong, not paying attention that they weren't highlighted right, missing imports, bah! So stupid.

    Flex/Flash Builder forces you to fix everything before you can compile, saves SOOOO much time omfg.

    • AMEN BROTHA!!!! The (basically) runtime code checking is very worth it. TM isn't bad, but not as complete.tommyo