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