ActionScript 3 Error: 1038: Target of break statement was not found.

ActionScript 3 Error: 1038: Target of break statement was not found.

ActionScript 3 Error #1038 Description:
A break statement is used only with loops. They will not work in if statements. This is directly from the documentation:

Appears within a loop (for, for..in, for each..in, do..while, or while) or within a block of statements associated with a particular case in a switch statement. When used in a loop, the break statement instructs Flash to skip the rest of the loop body, stop the looping action, and execute the statement following the loop statement. When used in a switch, the break statement instructs Flash to skip the rest of the statements in that case block and jump to the first statement that follows the enclosing switch statement.

In nested loops, break only skips the rest of the immediate loop and does not break out of the entire series of nested loops. To break out of an entire series of nested loops, use label or try..catch..finally.

The break statement can have an optional label that must match an outer labeled statement. Use of a label that does not match the label of an outer statement is a syntax error. Labeled break statements can be used to break out of multiple levels of nested loop statements, switch statements, or block statements. For an example, see the entry for the label statement.

Pay attention to the last two paragraphs if you want to break all the way out of a function/method rather than just the loop that the break statement is inside then you need to use label. A very handy but seldom used method

Flex / Flash Error #1038 Fix:
Make sure that your break statement is within a valid loop such as for, while, switch statements, etc… Another alternative is to use a return statement without any parameters. Warning: Using return will break out of the function entirely and will not execute any code after the if statement. return is typically used as the last line of code in a function.

Bad Code:

if (totalScore < 10)
{
finalMsg = “Sorry!<br /> You need more practice”;
break;
}
else if (totalScore < 20)
{
finalMsg = “Congratulations!<br /> You kept yourself and others safe”;
break;
}

Good Code:

if (totalScore < 10)
{
finalMsg = “Sorry!<br /> You need more practice”;
return;
}
else if (totalScore < 20)
{
finalMsg = “Congratulations!<br /> You kept yourself and others safe”;
//break can be removed to get rid of the error;
}

This should help you resolve Flex / Flash Warning #1038

Thanks and as always Happy Flashing

Curtis J. Morley

ActionScript 3 Error #1061

ActionScript 3 Error #1061: Call to a possibly undefined method addEvent through a reference with static type flash.utils:Timer.

ActionScript 3 Error #1061 Description:
AS3 error 1061 appears when you have misspelled a property or function and have not assigned a value to it. If you haven’t properly typed the Object to begin with you will get AS3 Error 1069. See the examples below. AS3 error 1061 is actually pretty nice to work with because it tells you exactly which method/property didn’t work and it tells you which object it didn’t work on.

Flash / Flex Error 1061 Fix:
Find the object listed in the error and then check the spelling after the dot.

Bad Code 1:

var t:Timer = new Timer(1000, 60);
t.addEvent(TimerEvent.TIMER, Tick);

Good Code 1:

var t:Timer = new Timer(1000, 60);
t.addEventListener(TimerEvent.TIMER, Tick);

Related ActionScript Error(s):
Flash / Flex Error 1069
– You will get AS3 Error 1069 instead of 1061 if you don’t properly type your object before referencing a property on it. For example var t:Timer = new Timer(1000, 60);
t.addEvent(TimerEvent.TIMER, Tick); will give error 1061 but var t = new Timer(1000, 60);
t.addEvent(TimerEvent.TIMER, Tick); will give Error 1069.
Flash / Flex Error 1119
The dreaded AS 3 Error 1119
Flash / Flex Error 1056
– This is the error you will get if you try and call a property with a misspelled name in the same way as calling a property with a misspelled name.

ReferenceError: Error #1069: Property addEvent not found on flash.utils.Timer and there is no default value

ReferenceError: Error #1069: Property addEvent not found on flash.utils.Timer and there is no default value.

ActionScript 3 Error #1069 Description:
AS3 error 1069 appears when you have misspelled a property or function and have not assigned a value to it. If you have properly typed the Object to begin with you will get AS3 Error 1061. See the examples below. AS3 error 1069 is actually pretty nice to work with because it tells you exactly which method/property didn’t work and it tells you which object it didn’t work on.

Flash / Flex Error 1069 Fix:
Find the object listed in the error and then check the spelling after the dot.

Bad Code 1:

var t = new Timer(1000, 60);
t.addEvent(TimerEvent.TIMER, Tick);

Good Code 1:

var t = new Timer(1000, 60);
t.addEventListener(TimerEvent.TIMER, Tick);

This should help you resolve Flex / Flash Error #1069

Thanks and as always Happy Flashing

Curtis J. Morley

Related ActionScript Error(s):
Flash / Flex Error 1061
– You will get AS3 Error 1069 instead of 1061 if you don’t properly type your object before referencing a property on it. For example var t:Timer = new Timer(1000, 60);
t.addEvent(TimerEvent.TIMER, Tick); will give error 1061 but var t = new Timer(1000, 60);
t.addEvent(TimerEvent.TIMER, Tick); will give Error 1069.
Flash / Flex Error 1119
Flash / Flex Error 1056
– 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.

AS3 Warning: 1102: null used where a int value was expected.

ActionScript 3 Warning: 1102: null used where a int value was expected.

ActionScript 3 Warning#1102 Description:
This warning is pretty good at describing what is happening but is needs to add a little to explain why. This error will appear when you try and force a variable to be a certain Type within a predefined function. For example if you have a variable like _minute below

Flex / Flash Warning1102 Fix:
Find where you are using null and make sure that you are using the proper value

Bad Code:

var TargetDate:Date = new Date(_year, _month, _date, _hour, _minute=null);

or

var TargetDate:Date = new Date(_year, _month, _date, _hour, _minute=”10″);

or

var TargetDate:Date = new Date(_year, _month, _date, _hour, _minute=false);

Good Code:

var TargetDate:Date = new Date(_year, _month, _date, _hour, _minute=10);

Warning:
You will not get this error with the code below even though it seems like the same as the code above. The smart folks at Adobe put in logic that will accommodate for numbers-as-strings and also boolean which will result in the number 0.  The AS3 Warning will will only show when you assign an non-permitted variable within the parameters of a method call. The code below will output a valid date. Direct assignment in quotes will be translated into a valid Number not an int. False shows up as 0 in the date.

var TargetDate:Date = new Date(_year, _month, _date, false, 10“);

Related AS3 Error:
AS3 Error 1067

This should help you resolve Flex / Flash Warning #1102

Thanks and as always Happy Flashing

Curtis J. Morley

New Info added to AS3 Error 1067

Check out the new info I posted on AS3 Error #1067

It is highly related to AS3 Warning 1102

Thanks,

Curtis J. Morley

ActionScript 3 Error #2078

Flash / Flex Error #2078: The name property of a Timeline-placed object cannot be modified.

ActionScript 3 Error #1061 Description:
The MovieClip or Button that you have on the stage cannot be changed with code. It already has a name so you can’t change it. If you are visiting this page my guess is that you are thinking that you have a dynamic movieClip that you named with code, yet you probably have one with the same name on the stage already.

Flash / Flex Error 1061 Fix:
Stop trying to change a named object on the stage that already has one.

Bad Code:

myMovieClip.name = “Bob”;

Good Code:

//no code here

Thanks and Happy Flashing

Curtis J. Morley

AS3 Error 1188: Illegal assignment to class Boolean.

ActionScript Error #1188: Illegal assignment to class Boolean.

ActionScript Error #1188: Illegal assignment to class Number.

ActionScript Error #1188: Illegal assignment to class int.

ActionScript Error #1188: Illegal assignment to class uint.

ActionScript Error #1188: Illegal assignment to class String.

ActionScript Error #1188: Illegal assignment to class Array.

ActionScript Error #1188: Illegal assignment to class Object.

ActionScript 3 Error #1188 Description:

AS3 error 1188 is thrown when the keyword “var” is omitted. Adobe doesn’t offer any documentation on this ActionScript Error and the description itself is no help at all. This error will be thrown whenever the “var” keyword is missing on all variable assignments including a custom Class/Data Type. I have never experienced this error without also getting AS3 Error 1067 first.

Flex / Flash Error 1188 Fix:
Don’t forget the var when you define a new variable.

Bad Code:

import com.errors.CustomObj
myCustomObj:CustomObj = new CustomObj();
myObj:Object = new Object();
myBool:Boolean = false;
myint:int = -1;
myString:String = “Happy Flashing”;
myArray:Array = new Array();

Good Code:

import com.errors.CustomObj
var myCustomObj:CustomObj = new CustomObj();
var myObj:Object = new Object();
var myBool:Boolean = false;
var myint:int = -1;
var myString:String = “Happy Flashing”;
var myArray:Array = new Array();

Related Errors:

ActionScript Error 1067

This should help you resolve Flex / Flash Error #1188
Thanks and as always Happy Flashing

Curtis J. Morley

ActionScript Error 1083: Syntax error: doubledot is unexpected.

ActionScript Error 1083: Syntax error: doubledot is unexpected.

var intLat:Number = ((Math.random()*1)*..00060

ActionScript 3 Error #1083 Description:
AS3 error 1083 says that you have too many dots.  Look carefully at the line of code and you will most likely see that your speedy typing fingers hit the period one too many times.  This can happen while targeting an object or when you are using decimals.  Doubledot is valid in AS3 but only in the context of E4X.  You use doubledot otherwise known as the descendent accessor (..) operator to access child properties of an XML object.

Flex / Flash Error 1083 Fix:
Remove the extra dot.

Bad Code 1:

var intLat:Number = myNumber * ..0006;

Good Code 1:

var intLat:Number = myNumber * .0006;

Bad Code 2:

this..myObj.x = 100;

Good Code 2:

this.myObj.x = 100;

This should help you resolve Flex / Flash Error #1083

Thanks and as always Happy Flashing

Curtis J. Morley

ActionScript Error #1067 – Implicit coercion of a value of type void to an unrelated type Function.

ActionScript Error #1067: Implicit coercion of a value of type void to an unrelated type Function.

ActionScript 3 Error #1067 Description:
AS3 error 1137 is describing the fact that you have entered a parameter that is not supposed to be inside the parenthesis.

Flex / Flash Error 1067 Fix:
Remove all parameters from within the parenthesis.

Bad Code 1:

alone_btn.addEventListener(MouseEvent.MOUSE_UP, trace(“The message”));

Good Code 1:

alone_btn.addEventListener(MouseEvent.MOUSE_UP, traceMe);
function traceMe (e:MouseEvent)
{
trace(“The message”);
}

AS3 Error # 1067: Implicit coercion of a value of type String to an unrelated type int.

ActionScript 3 Error #1067: Implicit coercion of a value of type Boolean to an unrelated type int.

Bad Code 2:

var TargetDate:Date = new Date(_year, _month, _date, _hour, _minute=false);

or

var TargetDate:Date = new Date(_year, _month, _date, _hour, _minute=String);

Good Code 2:

var TargetDate:Date = new Date(_year, _month, _date, _hour, _minute=10);

AS3 Error 1067 Fix #2 – In the example below you will see that the function “Return Type” is listed as “int” when it needs to be listed as String.  To fix this simply change the Return Type to String or return a valid integer.

Bad Code:

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

Good Code:

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

Related Error(s):
Flash / Flex Error 1188
AS3 Warning 1102

This should help you resolve Flex / Flash Error #1067

Thanks and as always Happy Flashing

Curtis J. Morley

Flex / Flash Error 1137

ActionScript Error #1137: Incorrect number of arguments. Expected no more than 0.

ActionScript 3 Error #1137 Description:
AS3 error 1137 is describing the fact that you have entered a parameter that is not supposed to be inside the parenthesis.

Flash Error 1137 Fix:
Remove all parameters from within the parenthesis.

Bad Code:

var fileToLoad:URLRequest = new URLRequest(“cleanhandsworkahsc.swf”)
var myLoader:Loader = new Loader(fileToLoad);
this.addChild(myLoader);

Good Code:

var fileToLoad:URLRequest = new URLRequest(“cleanhandsworkahsc.swf”)
var myLoader:Loader = new Loader();
myLoader.load(fileToLoad);
this.addChild(myLoader);

This should help you resolve Flex / Flash Error #1137

Thanks and as always Happy Flashing

Curtis J. Morley