Skip to main content
Participant
July 1, 2013
Answered

1013: The private attribute may be used only on class property definitions.

  • July 1, 2013
  • 2 replies
  • 752 views

In the following code I get an error. How to solve this?

Line 301013: The private attribute may be used only on class property definitions.

package

{

          import flash.display.MovieClip;

          import flash.events.Event;

 

          public class Caesar extends MovieClip

          {

                    var velocity:Number;

 

                    public function Caesar()

                    {

                    addEventListener("enterFrame"), move;

                    }

 

          public function move(e:Event)

          {

                    this.x = mouseX;

                    this.y = mouseY;

 

                              if (caesar.hitTestObject(MainClip.instance.enemyList))

                              {

                                        trace ("caesar geraakt");

                                        removeSelf();

                                        MainClip.instance.finishedMainClip();

                              }

          }

 

          }

 

          private function removeSelf():void

          {

                    removeEventListener(Event.ENTER_FRAME, move);

                    if (stage.contains(this))

                    {

                              this.parent.removeChild(this);

                    }

          }

}

This topic has been closed for replies.
Correct answer Ned Murphy

Check your indents... Your removeSelf function is outside of the class definition... that closing brace before it should be after it.

2 replies

Inspiring
July 2, 2013

You have an extra curly bracket before removeSelf() method and missing bracket at the end. The class should look like this:

package

{

          import flash.display.MovieClip;

          import flash.events.Event;

 

          public class Caesar extends MovieClip

          {

                    private var velocity:Number;

 

                    public function Caesar()

                    {

                              addEventListener("enterFrame"), move;

                    }

 

                    public function move(e:Event)

                    {

                              this.x = mouseX;

                              this.y = mouseY;

 

                              if (caesar.hitTestObject(MainClip.instance.enemyList))

                              {

                                        trace("caesar geraakt");

                                        removeSelf();

                                        MainClip.instance.finishedMainClip();

                              }

                    }

 

                    private function removeSelf():void

                    {

                              removeEventListener(Event.ENTER_FRAME, move);

                              if (stage.contains(this))

                              {

                                        this.parent.removeChild(this);

                              }

                    }

 

          }

}

Ned Murphy
Ned MurphyCorrect answer
Legend
July 1, 2013

Check your indents... Your removeSelf function is outside of the class definition... that closing brace before it should be after it.

7416bramAuthor
Participant
July 1, 2013

Then I get the following errors:

Line 121136: Incorrect number of arguments.  Expected 2.
Line 201120: Access of undefined property caesar.
Line 201120: Access of undefined property i.
Ned Murphy
Legend
July 1, 2013

Those are not a result of fixing the first, they are just more errors found after fixing the first.

If you look at line 12 and don't see the problem, spend more time looking at it and how to add an event listener.

As for the other two... the errors are telling you your class does not know what caesar and i are.  If you do not define them for the class then they will be undefined.