Search code examples
actionscript-3buttonsyntax-errorflashdevelop

FlashDevelop Syntax Error: Expecting Identifier Before Public


I'm new to AS3, and I would really appreciate any help you can give me! I am trying to create a button. However, FlashDevelop keeps telling me I have a Syntax Error in:

  1. Line 11 Col. 2 (Syntax Error: expecting identifier before public)
  2. Line 11 Col. 40 (Syntax Error: expecting identifier before extends)
  3. Line 13 Col. 2 (Error: the private attribute may only be used on class property definitions)

Below is my code:

package 
{
 import flash.display.Sprite;
 import flash.events.Event;
 import flash.display.Graphics;
 import flash.
 /**
 * ...
 * @author 15leungjs1
 */
 public class Main extends Sprite 
 {
 private var button:Sprite;

 public function Main():void 
 {
 //Create a new instance of a Sprite to act as the button graphic.
 button = new Sprite();

 //Set the color of the button graphic
 button.graphics.beginFill(0xFFAD3B);

 //Set the X,Y, Width, and Height of the button graphic
 button.graphics.drawRect(10, 0, 200, 100);

 //Apply the fill
 button.graphics.endFill();

 //Add Handcursor,buttonMode, and mouseChildren
button.buttonMode = true;
button.useHandCursor = true;
button.mouseChildren = false;

 //Add Button Sprite to stage
 this.addChild(button);
 }
 }
} 

}

Solution

  • The problem is simple...

    You have the following line of code (line 6) that is not finished correctly:

    import flash.
    

    You need to complete that import statement or remove it completely.