Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

New Here ,
Jul 01, 2013 Jul 01, 2013

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);

                    }

          }

}

TOPICS
ActionScript
690
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jul 01, 2013 Jul 01, 2013

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

Translate
LEGEND ,
Jul 01, 2013 Jul 01, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 01, 2013 Jul 01, 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 01, 2013 Jul 01, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 01, 2013 Jul 01, 2013
LATEST

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);

                              }

                    }

 

          }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines