Flex 2 / Flash CS3 ActionScript Error #1013

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

Description:
This ActionScript Error justs means that you have used the access control modifier ‘private’ in the wrong spot. There are four access control modifiers – public, private, internal, and protected. Each of these specify how the method or variable is accessed. Each access control modifier has it’s own error but they all mean the same thing. Access control modifiers need to be used in the right place. The ‘internal’ and ‘public’ can only be used inside a ‘package’ and ‘private’ and ‘protected’ can only be used on classes. AS3 error 1013 can also be caused if you misplace a method identifier like ‘:void’

Fix:
Make sure to only use the ‘private’ access control modifier to define a method or variable within the class itself and not within a method(function).

Bad Code 1:

package{
	public class MySize {
		public function Connection():void{
			private var size:uint = 40;
			trace(size);
		}
	}
}

Good Code 1:

package{
	public class MySize {
		private var size:uint = 40;
		public function Connection():void{
			trace(size);
		}
	}
}

or

package{
	public class MySize {
		public function Connection():void{
			var size:uint = 40;
			trace(size);
		}
	}
}

Bad Code 2:

package{
	public class MySize {
		public function Connection():void{
			someFunction():void;
		}

 	private function someFunction():void{
			var size:uint = 40;
			trace(size);
		}
	}
}

Good Code 2:

package{
	public class MySize {
		public function Connection():void{
			someFunction();
		}

 	private function someFunction():void{
			var size:uint = 40;
			trace(size);
		}
	}
}

Related ActionScript Errors – AS3 Error 1114, AS3 Error 1115 , AS3 Error 1150

This ActionScript Error is a quick one. I hope this helps you solve it.

As always Happy Flashing

13 thoughts on “Flex 2 / Flash CS3 ActionScript Error #1013

  1. hey!!
    i seem to get the error message 1084 sytax error: expecting identifier before lessthan. can u pls. tell mi how to rectify it!!
    thank you

  2. “private function startTrailer(e:MouseEvent): void” needs a closing brace }

    When you get this error, the very first thing you should check for is typos.

  3. wow…

    That is the same code as AIFL above me… 🙂 well probably from the same tutorial site..nevertheless the error is coming to all who use it..so there is something wrong somewhere in that code…Can someone please help correcting it.

    I am an absolute new learner so cant figure out where it is going wrong.. 🙁

    Cheers!

  4. Hi,

    here is my code…and its giving me error :1013 private attribute may used only class property definitions:

    on line25: private function animate(e:Event):void

    Please help!!

    code:
    package
    {
    import flash.display.Sprite;
    import flash.ui.Mouse;
    import flash.events.MouseEvent;
    import flash.events.Event;

    public class MouseTrailer extends Sprite
    {
    var lightBall:LightBall;

    public function MouseTrailer():void {
    Mouse.hide();
    stage.addEventListener(MouseEvent.MOUSE_MOVE, startTrailer);
    }
    private function startTrailer(e:MouseEvent):void {
    lightBall = new LightBall();
    lightBall.x = mouseX + Math.random() * lightBall.width;
    lightBall.y = mouseY + Math.random() * lightBall.height;

    addChild(lightBall);

    lightBall.addEventListener(Event.ENTER_FRAME, animate);

    private function animate(e:Event):void
    {
    e.target.alpha -= 0.05;
    //if lightBall is no longer visible, remove it
    if (e.target.alpha <=0)
    {
    e.target.removeEventListener(Event.ENTER_FRAME, animate);
    removeChild(e.target as Sprite);
    }
    e.target.scaleX -= 0.1;
    e.target.scaleY -= 0.1;
    e.target.y +=3;
    }
    }
    }
    }

  5. I have the same error, but can’t seem to figure it out. Here is my code.

    package {
    import flash.display.Sprite;
    import flash.ui.Mouse;
    import flash.events.MouseEvent;
    import flash.events.Event;

    public class MouseTrailer extends Sprite {
    var lightBall:LightBall;

    public function MouseTrailer():void {
    Mouse.hide();
    stage.addEventListener(MouseEvent.MOUSE_MOVE, startTrailer);
    }

    private function startTrailer(e:MouseEvent):void {

    /* Create a new LightBall object */

    lightBall = new LightBall();

    /* Position */

    lightBall.x = mouseX + Math.random() * lightBall.width;
    lightBall.y = mouseY – Math.random() * lightBall.height;

    /* Add to Stage */

    addChild(lightBall);

    /* Add Listener to Animate function */

    lightBall.addEventListener(Event.ENTER_FRAME, animate);

    private function animate(e:Event):void {

    /* Alpha */

    e.target.alpha -= 0.05;

    /* If lightBall is no longer visible, remove it */

    if (e.target.alpha <= 0) {
    e.target.removeEventListener(Event.ENTER_FRAME, animate);

    removeChild(e.target as Sprite);
    }
    /* Scale */

    e.target.scaleX -= 0.1;
    e.target.scaleY -= 0.1;

    /* Y Position */

    e.target.y += 3;
    }
    }
    }
    }

  6. In my case the problem was an if statement…

    it was something like

    if (a != b) ;
    trace(a-b);
    }

    just a syntax error after the conditional… hope it helps

  7. Pingback: curtismorley.com » Flex / Flash ActionScript Error #1095

  8. Gary,

    Sorry the comment field sometimes chops off the code. Could you try including the rest of the code especially the package, constructor and curly braces. Check to make sure that you don’t have any rogue braces that are misplaced and that this function is nested inside the Class.

    Let me know how it works for you and as always Happy Flashing.

    Curtis

  9. My code looks very similar to yours but i still cant seem to find the error
    here is a sample of the code

    private function dispatchColorPicked(mouseEvent:MouseEvent):void
    {

    can you help me out

  10. Pingback: curtismorley.com » Flex 2 / Flash CS3 ActionScript Error #1114

  11. Pingback: curtismorley.com » Flex 2 / Flash CS3 ActionScript Error #1115

  12. Pingback: curtismorley.com » Flex 2 / Flash CS3 ActionScript Error #1150

Comments are closed.