ActionScript ReferenceError: Error #1056

ReferenceError: Error #1056: Cannot create property _x on flash.display.Sprite

or

ReferenceError: Error #1056: Cannot create property someVar on flash.text.TextField.

ActionScript 3 Error #1056 Description:
AS3 error 1056 appears when you have improperly referenced a property of an object. This will happen when you misspell something or when you reference variables in the AS2 fashion with a leading underscore ( _ ). AS3 error 1056 is actually pretty nice to work with because it tells you exactly what variable didn’t work and it tells you which object it didn’t work on.

You can also get this error if you try to dynamically assign a variable to an object that doesn’t naturally accept one like a textField.  See Bad Code 3.

Flash / Flex Error 1056 Fix:
Simply spell the property correctly or make sure that you are using AS3 Syntax instead of AS2.


Bad Code 1:

var s = new Sprite();
s._x = 100;

Good Code 1:

var s = new Sprite();
s.x = 100;

Bad Code 2:

var t = new Timer(1000, 4);
t.dela = 500;

Good Code 2:

var t = new Timer(1000, 4);
t.delay = 500;

Bad Code 3:

myTextField.someVar = “something”;

This should help you resolve Flex / Flash Error #1056

Thanks and as always Happy Flashing

Curtis J. Morley

Related ActionScript Error(s):
Flash / Flex Error 1119
– You will get AS3 Error 1056 instead of 1119 if you don’t properly type your object before referencing a property on it. For example var s:Sprite = new Sprite(); s._x = 10; will give error 1119 but var s = new Sprite(); s._x = 10; will give Error 1056.
Flash / Flex Error 1151
Flash / Flex Error 1069
– This is the error you will get if you try and call a method with a misspelled name in the same way as calling a property with a misspelled name.

ActionScript Error #1024

ActionScript Error #1024: Overriding a function that is not marked for override.

Description:
AS3 error 1024 means that Flash or Flex already has a function by that name.

Fix:
To solve Flex/Flash Error 1024 all you need to do is either correctly name the function something besides a reserved function in Flex/Flash or properly override the function. The example below shows how to solve issue number one. Notice that the good code solves Error 1024 because it doesn’t use the same name as a function that already exists in ActionScript.

Bad Code 1:

function nextFrame (e:MouseEvent):void
{
this.nextFrame();
}

Good Code 1:

function onNextFrame (e:MouseEvent):void
{
this.nextFrame();
}

This should help you resolve Flash / Flex Error #1024

Thanks and as always Happy Flashing

Curtis J. Morley

Flex 2 / Flash CS3 ActionScript Error #1105

ActionScript Error #1105: Target of assignment must be a reference value.

Description:
This ActionScript error simply means that you are trying to assign a value to something that is already a value and not a variable or a writable property. Adobe Live Docs actually has a pretty good definition about this one. It says, ” You can assign a value to a variable, but you cannot assign a value to another value.” To make this simple let me use an example. An array has a property length. An XMLList also has a property called length() . Pay attention to the parenthesis. An array will let you change the length of the array simply by calling my_array.length = 2; because it is a readable and writable property. When using XML however the length property is only readable so my_xml.length() = 0; is like saying 2 = 0; You can not change the value 2.

Fix:
When you get this ActionScript error make sure to check that you are not trying to change a value. Also make sure that the property is readable and writable.

Bad Code:

my_xml.children().length() = 0;

Good Code:

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

Good luck trouble shooting ActionScript Error #1105 and,
As always Happy Flashing

ActionScript Error #2032

ActionScript Error #2032: Stream Error. URL: /Sound/Amazing.mp3

Description:
This is an ActionScript Runtime Error that you will get if you purposefully trap errors (which I highly recommend you do) while trying to load a file into Flash/Flex. One very simple reason you will get this error is if you have targeted an mp3 or any file incorrectly. This can include php scripts and other external datasources.

Fix:
Make sure that you are targeting the file correctly. In the ‘Bad Code’ example below I am missing just one letter. Without trapping the errors like I do you will also get AS3 Error #2044: Unhandled IOError Event

Bad Code:

private var snd:Sound = new Sound();
snd.load(new URLRequest(“Amzing.mp3”));
snd.addEventListener(IOErrorEvent.IO_ERROR, onSoundIOError, false, 0, true);

function onSoundIOError (e:IOErrorEvent)
{
trace(“An Error Occured and it looked like this.”, e.text);
}
snd.play();

Good Code:

private var snd:Sound = new Sound();
snd.load(new URLRequest(“Amazing.mp3”));
snd.addEventListener(IOErrorEvent.IO_ERROR, onSoundIOError, false, 0, true);

function onSoundIOError (e:IOErrorEvent)
{
trace(“An Error Occured and it looked like this.”, e.text);
}
snd.play();

Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.
at SoundControl_fla::MainTimeline/frame1()

Related ActionScript Errors – AS3 Error 2044 Unhandled IOError Event

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

As always Happy Flashing

New Scenarios of AS3 Error #1084

I’ve added 3 new scenarios to AS3 error 1084.

You can find it here.

http://curtismorley.com/2007/07/14/flash-cs3-flex-2-error-1084/#comment-2482

The additions are:

1084: Syntax error: expecting leftparen before colon.
1084: Syntax error: expecting rightparen before colon.
1084: Syntax error: expecting rightparen before semicolon.

Flex 2 / Flash CS3 ActionScript Error #1150

ActionScript Error #1150: The protected attribute may be used only on class property definitions.

Description:
This ActionScript Error justs means that you have used the access control modifier ‘protected’ 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.

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

Bad Code:

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

Good Code:

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

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

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

As always Happy Flashing

Flex 2 / Flash CS3 ActionScript Error #1115

ActionScript Error #1115: The internal attribute can only be used inside a package.

Description:
This ActionScript Error justs means that you have used the access control modifier ‘internal’ 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.

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

Bad Code:

package{
	public class MySize {
		public function Connection():void{
			internal var bgColor:uint = 0xFFCC00;
			trace(bgColor);
		}
	}
}

Good Code:

package{
	internal class MySize {
		public var bgColor:uint = 0xFFCC00;
		public function Connection():void{
			trace(bgColor);
		}
	}
}

Related ActionScript Errors – AS3 Error 1013, AS3 Error 1114AS3 Error 1150
This ActionScript Error is a quick one. I hope this helps you solve it.

As always Happy Flashing

Flex 2 / Flash CS3 ActionScript Error #1114

ActionScript Error #1114: The public attribute can only be used inside a package.

Description:
This ActionScript Error justs means that you have used the access control modifier ‘public’ 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.

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

Bad Code:

package{
	public class MySize {
		public function Connection():void{
			public var bgColor:uint = 0xFFCC00;
			trace(bgColor);
		}
	}
}

Good Code:

package{
	public class MySize {
		public var bgColor:uint = 0xFFCC00;
		public function Connection():void{
			trace(bgColor);
		}
	}
}

or

package{
	public class MySize {
		public function Connection():void{
			var bgColor:uint = 0xFFCC00;
			trace(bgColor);
		}
	}
}

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

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

As always Happy Flashing

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

Flex 2/ Flash CS3 Error #3590

Flex 2/ Flash CS3 Warning / Error #3590: String used where a Boolean value was expected. The expression will be type coerced to Boolean.

or

Warning: 3590: int used where a Boolean value was expected. The expression will be type coerced to Boolean.

Description:
This is a ActionScript error is more of a warning than a true AS3 error. It will be displayed in strict mode and simply means that you have quotes around your Boolean value. Even though you may get this AS3 error it won’t prevent Flex or Flash from compiling nor ActinoScript code. It will convert it for you though. Thanks Flash for doing that for us.

AS3 Warning #3590 Fix 1:
Make sure that your boolean (true or false is not inside quotes).

Bad Code 1:

myObject.visible = “false”;

Good Code 1:

myObject.visible = false;

AS3 Warning #3590 Fix 2:
ActionScript 3 uses true and False rather than 0 and 1 for boolean. Although it does allow 0 to make it through without giving this error.

Bad Code 2:

myObject.visible = 1;

Good Code 2:

myObject.visible = true;

AS3 Warning 3590: Fix #3*Warning* This method will solve the problem temporarily and allow you to publish your code BUT it will cause you many headaches later. You will not get any warnings or error messages and this is a bad thing I Promise! If you are going to proceed down this path make sure to recheck these boxes after you are done publishing your one problem movie. With that much said, The way you do this is to turn off Strict (Verbose) Error Messages in your preferences as shown below.

Go to File >> Publish Settings >> Click on the “Flash” tab >> Next to “ActionScript version:” click the “Settings…”

AS3 Error 1118 -Implicit Coercion

AS3 Warning 3590 Fix #4 – In the example below you will see that the function “Return Type” is listed as Boolean when it needs to be listed as String.  To fix this simply change the Return Type to String or return a Boolean value “true” or “false”.

Bad Code:

function bob():Boolean
{
return “message”;
}

Good Code:

function bob():String
{
return “message”;
}

AS3 Warning 3590 is pretty easy and straight forward.

As always – Happy Flashing