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

Flex 2 / Flash CS3 Syntax Error #1100

Error #1100: Syntax error: XML does not have matching begin and end tags.

Description:
Here is another easy AS3 error. This Flex/Flash Error means that your XML is not valid because the end tag is simply missing or you left off the end slash (/). *Note: This AS3 error is similar to ActionScript Error #1085

Solution:
Close that end tag.

Bad Code 1

var dogXML:XML =
<dog>
<name>Fido
</dog>

or

var dogXML:XML = new XML();
dogXML =
<dog>
<name>Fido<name>
</dog>

Good Code

var dogXML:XML = new XML();
dogXML =
<dog>
<name>Fido</name>
</dog>

Related Errors:
ActionScript Error #1085

I hope this helps you solve ActionScript Error #1100

As Always Happy Flashing

Curtis J. Morley

Flash CS6 / Flex Error #1009: Cannot access a property or method of a null object reference

TypeError: Error #1009: Cannot access a property or method of a null object reference

ActionScript 3 Error #1009 is an AS3 that you can get for many anecdotal reasons. This error basically means that you are trying to reference something that isn’t there yet. That something can be a variable, data from the server, or even a movieClip or other display instance. So if you try and make a call to something and are getting this error simply look at what you are trying to reference and ask yourself is it there yet.
Don’t bang your head against the wall any longer. Here I explain one of the most un-obvious ways to get this error.

One reason that you will get AS3 Error #1009 is because you are trying to access a movieClip that isn’t instantiated yet. For example you try and reference a movieClip named loader_mc that is inside another movieClip. you are referencing it from a class that you created. Each time you run the test the movie you get the Run-Time Error #1009. You look inside your movieClip and see that the loader_mc is right where you want it. It is on frame 10 inside your animated moveiClip. That is when it dawns on you that the call to loader_mc happens when it is instantiated. Simply, put loader_mc on frame 1 and change it’s alpha to 0 and then the movieClip will be instantiated when the call from your custom class is made.

Another reason for this error is simply incorrect targeting. If you target parent.bob and the correct reference is parent.parent.bob then you will get this error as well.

Fix 1 :

Make sure the the reference is instantiated before it is called.  This means that the script is run after the object is loaded or the frame in the animation has been reached etc…

Fix 2 :

Check your targeting

Thanks and Happy Flashing

Flash CS3 / Flex 2 / AS3 Error #1176

Flash CS3 / Flex 2 / AS3 Error #1176: Comparison between a value with static type String and a possibly unrelated type int.

Problem:
Flash won’t compile because it doesn’t like to compare an int with a String.

Fix:
Thank heavens for Strict Typing. Without it we wouldn’t get such nice errors. Just change the type from an “int” to a String and you will be on your way.  If you need it to really be an int then you can cast the second variable to be an int rather than a String. See code example below

Bad Code:

var dropNum:int;function bob():void
{
var myText:String = “2”;
var curNum:String = “3”;
dropNum = myText.substr(0,1);
if (curNum == dropNum) {
someCode();
}
}

Good Code:

var dropNum:String;

function bob():void
{
var myText:String = “2”;
var curNum:String = “3”;
dropNum = myText.substr(0,1);
if (curNum == dropNum) {
someCode();
}
}

or

var dropNum:int;

function bob():void
{
var myText:String = “2”;
var curNum:int = 3;

dropNum = Number(myText.substr(0,1));
if (curNum == dropNum) {
someCode();
}

Hope this helps solve ActionScript Error 1176 and Happy Flashing

Curtis J. Morley

Flash CS3 / Flex 2 AS3 Warning: #3596: Duplicate variable definition.

Warning: 3596: Duplicate variable definition.

Problem:
You are using the same variable and Flex/Flash doesn’t like it.
Fix:
Change the name of one instance or unnest your loop.

Bad Code:

var myArray1:Array = [“a”,”b”,”c”,”d”,”e”];
var myArray2:Array = [myArray1];

//This first loop goes through the parent array
for (var i:int=0; i < myArray2.length; i++)
{
//this second loop iterates through the nested array
for (var i:int=0; i < myArray1.length; i++)
{
trace(myArray2[i][i]);
}
}

Good Code:

var myArray1:Array = [“a”,”b”,”c”,”d”,”e”];
var myArray2:Array = [myArray1];

//This first loop goes through the parent array
for (var i:int=0; i < myArray2.length; i++)
{
//this second loop iterates through the nested array
for (var j:int=0; j < myArray1.length; j++)
{
trace(myArray2[i][j]);
}
}

or

var keys:String = “Word”;
for (var i:int=0; i < keys.length; i++)
{
//Code
}

for (i=0; i < keys.length; i++){
//More Code
}

Once Again – Happy Flashing

Flash CS3 / Flex 2 AS3 Error #1119

Error #1119:
Access of possibly undefined property buttonText through a reference with static type flash.display:SimpleButton

or

Error #1119: Access of possibly undefined property someProperty through a reference with static type flash.display:DisplayObject.

Description:
This means that you are trying to change dynamic text nested inside a button. This is a simple fix. Just change the button to a movieClip.

Another more prevalent reason that you will get ActionScript Error #1119 is because the the new way Flash/flex handles parent objects has changed. In AS2 parent.myVar would work just fine. In ActionScript3 the compiler doesn’t know what the parent is unless specifically typed or casted instead it chalks everything up to DisplayObjectContainer. This means that it doesn’t know that the ‘parent’ is a MovieClip. The reason for this is because you can now change the object from one displayObject to another easily at compile time. You could change the parent object from a MovieClip to SimpleButton at compile time.

You also want to check your syntax to make sure that you have dynamically targeted an object correctly. For example, if you are trying to use AS3 to target a series of movieClips dynamically and each of the names start with ‘card’ and have a sequential value as well then you must use the code in Fix3 to prevent AS3 Error #1119. Fix #4 is similar to Fix 3 but Fix 4 is specific to the DisplayObject.
Fix 1:
You need to cast the parent as the type that you want or you need.

myTextField.text = MovieClip(this.parent).someVar
or
myTextField.text = (this.parent as MovieClip).someVar

One of the best explanations of casting for this error is written up by Josh Tynjala go visit his blog called “Why doesn’t the ‘parent’ property work the same in ActionScript 3”

.

Fix 2:
Rather than looking outside the movie for the variable you can push the variable into the child movieClip and then access it within itself. For example if I have a movieClip named bob that is inside of a clip named joe then I would have Joe push the variable into bob and bob would access it within himself and not need to ask his parent for the variable because he already has it.

From Joe

bob.someVar = “This is the variable”;

From Bob

myTextField.text = someVar;

Fix 3:

Bad Code:

this.card[i].id = “something”;

Good Code:

this[“card”+i].id = “something;

Fix 4:
The good code below uses a direct reference to the object that holds the property someProperty. Whereas the Bad Code example is trying to access the property through a reference through the displayObject. Because the displayObject doesn’t have the property it cannot change it.

Bad Code:

this.getChildByName(‘card’+_setClicksCounter).someProperty = true;

Good Code:

this[“card”+_setClicksCounter].someProperty = true;

Fix 5:
1119: Access of possibly undefined property nestedMovieClip through a reference with static type Class.
This is easy to fix. It just means that you are trying to access a nested object within the class statement rather than from within the Class. The problem is that the keyword “this” in the first example doesn’t references the Class itself rather the object the Class is linked to.

Bad Code:

package com.cjm.sound
{
public class SoundControl extends MovieClip
{
var _progwidth:uint = this.progBar.width;
public function SoundControl (url=null):void
{
doSomething();
}}}

Good Code:

package com.cjm.sound
{
import flash.display.MovieClip;
public class SoundControl extends MovieClip
{
var _progwidth:uint;
public function SoundControl ():void
{
_progwidth = this.progBar.width;
}}}

Related Errors:
Flash / Flex Error 1056 – 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.

As always – Happy Flashing