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

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