AS3 Error 1195: Attempted access of inaccessible method cacheAsBitmap through a reference with static type flash.display:DisplayObject.

AS3 Error 1195: Attempted access of inaccessible method cacheAsBitmap through a reference with static type flash.display:DisplayObject.

Description:
Error 1195 can have any number of methods listed in this AS3 Error so I probably should have listed it as Attempted access of inaccessible method someMethod through a reference with static type variableType. This is caused because you are either calling a private method from another class, or calling a method defined in a namespace that is not in use.

Solution:
If you are calling a method defined in an unused namespace, add a use statement for the required namespace. Otherwise, check that the method is within scope and accessible.

Thanks and Happy Flashing

Curtis J. Morley

AS3 Error #1126: Function does not have a body.

ActionScript Error 1126: Function does not have a body.

ActionScript Error 1126 Description:

I got this error from one of my UVU students code.  And as promised in honor of her I am thusly naming AS3 Error 1126 the Erin Johnson Error.  This error is given, in this case, because a semicolon is used instead of a colon after the parenthesis.  A semicolon in the ActionScript language is equivalent to a period in the English Language which means that if Flash sees the semicolon it says to the compiler finish this line of code and move on. The colon on hte other hand is used to say what Type something is or in the examples below what “Type” of data will be returned when the function is called. In the example below we don’t want to return a type so we use :void (notice the colon). This should help solve AS3 Error 1126.

 

Flex / Flash Error #1126 Fix:
Replace the semicolon with a colon.

Bad Code 1:

function someFunc(event:MouseEvent);void
{
doSomething();
}

Good Code 1:

function someFunc(event:MouseEvent):void
{
doSomething();
}

Related Errors:

ActionScript Error 1084: Syntax error: expecting colon before leftparen. This error is a psuedo error in this case because once AS3 Error 1126 is reslved this error will also disappear.

This should help you resolve Flex / Flash Error #1126

Thanks and as always Happy Flashing

Curtis J. Morley

ActionScript Security Error 2060: Security sandbox violation

ActionScript Security Error 2060: Security sandbox violation: ExternalInterface caller
file:///C:/Curtism/ExternalInterface_GA.swf
cannot access
file:///C:/Curtism/ExternalInterface_GA.html

Description:This error pops up when you are testing or deploying a web page that uses ExternalInterface to call a Javasacript function on the containing HTML page.  You may see this error when using Flooglytics (Flash and Google Analytics) or whenAjax is used in conjunction with Flash.  It basically means that what you are doing is not allowed with the way you have embedded your swf.  It is a really simple solution to fix this ActionScript Security Error

Flex / Flash Security Error #2060 Fix:
In the HTML make sure that the parameter ‘allowscriptaccess’ is set to ‘always’ rather than ‘sameDomain’ or ‘never’ in all cases.  Do a search in your HTML for allscriptaccess and change all references.  Usually there is two places to cahnge this.

Bad HTML Code using swfObject 2.0:

so.addParam('allowscriptaccess', 'sameDomain');

Good HTML Code using swfObject 2.0:

so.addParam('allowscriptaccess', 'always');

————————————————-

Bad HTML Code using AC_FL_RunContent:

‘allowScriptAccess’,‘sameDomain’,

Good HTML Code using AC_FL_RunContent:

‘allowScriptAccess’,‘always’,

————————————————-

Bad HTML Code using embed tag:

allowscriptaccess="sameDomain"

Good HTML Code using embed tag:

allowscriptaccess="always"

————————————————-

Bad HTML Object tag:

<param name=”allowScriptAccess” value=“sameDomain” />

Good HTML Object tag:

<param name=”allowScriptAccess” value=“always” />

————————————————-

This should help you resolve ActionScript Securtiy Error #2060

Thanks and as always Happy Flashing

Curtis J. Morley

ActionScript Error 1184: Incompatible default value of type int where String is expected.

ActionScript Error 1184: Incompatible default value of type int where String is expected.

ActionScript Error 1184 Description:
This error is quite simple.  It just says that you have the wrong type of data in your parameter initializer.  Or in other words you tried to assign a string where you typed the parameter as a uint.

Flex / Flash Error #1184 Fix:
Match the parameter type to the proper data type.

Bad Code 1:

bob(someValue:uint = “Happy”)
{
trace(someValue);//error 1184
}

Good Code 1:

bob(someValue:uint = 5)
{
trace(someValue);//output 5
}

Related Errors:

AS3 Error 1047

This should help you resolve Flex / Flash Error #1184

Thanks and as always Happy Flashing

Curtis J. Morley

ActionScript Error 1047: Parameter initializer unknown or is not a compile-time constant.

ActionScript Error 1047: Parameter initializer unknown or is not a compile-time constant.ActionScript Error 1047

Description:
Let’s break down ActionScript Error 1047 into it’s various parts.

  1. Parameter = The variable inside the parenthesis of a function
  2. Initializer = An initial value set on the parameter inside the parenthesis
  3. Compile-time Constant = Something Flash knows the value of without evaluating

So long story short – you are trying to assign a value to a parameter that has to be evaluated.  Still don’t know what I mean?  Check the code examples.

This is actually a really great feature of AS3.  Say for example you have an event listener that calls a function.  You also want to call this same function without the event. Unless you pass a value in you will get AS3 Error 1136.  AS3 allows you to set the Event parameter to null and therefore accept a call to that function without passing in a parameter.  function myUtilFunc( e:Event = null);

You can initialize and function with any Compile time constant for example a string like “Happy”, a constant like null or an int like 5 but you can not throw in anything that needs to be evaluated like a variable, math operation, an in-line array like [a,b,c] or date.

Flex / Flash Error #1047 Fix:
Remove any variable data and use only constants in the initializer such as Strings, Numbers, Null, etc…

Bad Code:

var init:String = “Happy”
function bob(someValue:String = init){
trace(someValue);
}

Good Code:

function bob(someValue:String = “Happy”){
trace(someValue);
}

or

function multiFunction(e:Event = null){
//doSomething;
}

Related Errors:

AS3 Error 1184

This should help you resolve Flex / Flash Error #1047

Thanks and as always Happy Flashing

Curtis J. Morley

Flex / Flash Compiler Error #1023: Incompatible override.

AS3 Compiler Error #1023: Incompatible override.

AS3 Error 1023 Description:

This ActionScript error is the most terse error that AS3 has provided us.  It is nothing like the beautiful description of AS3 Warning 1090

It popped up, rearing it’s ugly head like a teenager on Halloween. In most cases this error has more to do with AS3 Error 1021 than it does with an “Incompatible override”.   The first example below demonstrates this behavior. Example 1 will also give AS3 Error 1021 every time.

The second example is when an “Incompatible override” really is the reason.  Method signatures have to match or you will get this error.  Basically it means that you have not matched everything up properly from the method/Class that you are overriding.  So if you are overriding something that accepts events and you forget to put in events you will get this error.  If you give it a different Type you will get this error. Etc…

Adobe gives a good explanation of my second example.  They say:

“A function marked override must exactly match the parameter and return type declaration of the function it is overriding. It must have the same number of parameters, each of the same type, and declare the same return type. If any of the parameters are optional, that must match as well. Both functions must use the same access specifier (public, private, and so on) or namespace attribute as well.”

Flex / Flash Error #1023 Fix:

Make sure that you do not have duplicate names with an object and a function

or

Match the Method Signature of the soon to be overridden class.

Bad Code 1:

var myArray:Array = [1,2,3];

function myArray () {
}

Good Code 1:

var myArray:Array = [1,2,3];

function myArrayFunction () {
}

Bad Code 2:

override protected function draw(event:Event = null):void

Good Code 2:

override protected function draw(event:Event):void

Related Errors:

AS3 Error 3596
AS3 Error 1021
AS3 Error 1023 (Different error same number)

This should help you resolve Flex / Flash Warning #1023

Thanks and as always Happy Flashing

Curtis J. Morley

AS3 Compiler Error# 1021: Duplicate function definition.

AS3 Compiler Error# 1021: Duplicate function definition..

AS3 Error 1023 Description:

This ActionScript error is the most terse error that AS3 has provided us.  It is nothing like AS3 Warning 1090 It popped up, rearing it’s ugly head like a teenager on Halloween. In most cases this error has more to do with AS3 Error 1021 than it does with an incompatible override.  Sometimes it realy does mean that you have an override that is incompatible but many times it just means that you have a function that is named the same as

Flex / Flash Error #1021 Fix:

Do exactly what the message says use an event listener instead of the onRelease event that was common in AS2.

Bad Code 1:

function bob () {
}

function bob () {
}

Good Code 1:

function bob () {
}

function jim () {
}

Bad Code 2:

var myArray:Array = [1,2,3];

function myArray () {
}

Good Code 2:

var myArray:Array = [1,2,3];

function myArrayFunction () {
}

Related Errors:

AS3 Error 3596
AS3
Compiler Error 1023
AS3 Error 1023 (Different error same number.  This one has nothing to do with error 1021)

This should help you resolve Flex / Flash Warning #1021

Thanks and as always Happy Flashing

Curtis J. Morley

Flex / Flash Error 1042: The this keyword can not be used in static methods. It can only be used in instance methods, function closures, and global code.

ActionScript 3 Error: 1042: The this keyword can not be used in static methods. It can only be used in instance methods, function closures, and global code.ActionScript 3 Error #1042

AS3 Error 1042 Description:

AS3 Error1042 is actually a really helpful error.  It is simple in that it states that you will not be able to access something called “this” at the point in the code you are trying to access it.  In other words, you can’t put “this” directly inside the package or the class.  It can go in any of the functions that are within the Class but no higher.

It makes sense.  If you think about trying to access “this” from inside the package or from inside the class definition then you should understand why.  Packages are used only to show Flash/Flex where to find the code so there is no “this” in a file structure.  Also at the Class definition level this doesn’t exist either because the Class hasn’t yet run the constructor to make a “this”.

Flex / Flash Error #1042 Fix:

Remove the reference to the “this” keyword in your package or Class.

Bad Code:

package com.cjm.teaching{
import flash.display.MovieClip;
trace(this);
public class Ball extends MovieClip {
public function Ball():void {
}
}
}

or

package com.cjm.errors{
import flash.display.MovieClip;
public class MyClass extends MovieClip {
trace(this);
public function MyClass():void {
}
}
}

Good Code:

package com.cjm.errors{
import flash.display.MovieClip;
public class MyClass extends MovieClip {
public function MyClass():void {
trace(this);
}
}
}

Related Errors:

If the reference to “this” is at the package level you will also get AS3 Error 5000

This should help you resolve Flex / Flash Error #1042

Thanks and as always Happy Flashing

Curtis J. Morley

Flash Error #1180: Call to a possibly undefined method myCustomClass.

ActionScript 3 Error: 1180: Call to a possibly undefined method CustomClass.

ActionScript 3 Error #1180 Description:

One reason for this this error is because you are using the name of the variable that you are assigning to the Class rather than the Class itself.  Adobe also states that this error will only display when “Strict Mode” is turned on.

Flex / Flash Error #1180 Fix:

Make sure that when you instantiate the Object that you are using the Class name and not the variable name.

Bad Code:

var myCustomClass:CustomClass = new myCustomClass();

Good Code:

var myCustomClass:CustomClass = new CustomClass();

Links:

http://www.flashcomguru.com/index.cfm/2007/4/17/Flex-Builder-2-to-write-AS3-code-for-Flash

This should help you resolve Flex / Flash Error #1180

Thanks and as always Happy Flashing

Curtis J. Morley

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