I added a few more examples and a little more definition to ActionScript 3 Error #1078. There are now three code examples instead of just one and more in depth explanations to this error. I hope this helps you solve AS3 Error #1078.
Tag Archives: Web Development
Flash CS3 / Flex AS3 Error #1086
ActionScript Error: 1086: Syntax error: expecting semicolon before mult
Description:
This is a very easy and straightforward error with a horrible description. It actually has nothing to do with a semicolon at all. All this error means is that you forgot a ‘.’ in your import before the ‘*’.
Fix:
Add the Dot
Bad Code:
import flash.events*;
Good Code:
import flash.events.*;
Hopefully the confusing description for this ActionScript Error didn’t cause you to pull your hair out.
As Always Happy Flashing
Flash Error #1086: Syntax error: expecting semicolon before dot.
Description:
Another reason for the Flex / Flash Error #1086 is because a function/method call is typed. It is very important to type a function but do not type the call to the function.
Fix:
Remove the typing at the end of the method call.
Bad Code:
resource.readXml (requestId, onResourceXmlLoadSuccess, onResourceXmlLoadFail):void;
Good Code:
resource.readXml (requestId, onResourceXmlLoadSuccess, onResourceXmlLoadFail);
Happy Flashing
Flash CS3 / Flex AS3 Error #1053
ActionScript Error #1053: Accessor types must match.
Description:
This is a great error that has absolutely no documentation. This is what Adobe has to say about it.
Notice how the right side of the image doesn’t have any text at all. It is simply left blank. To understand this error you need to understand what an ‘Accessor’ is. An ‘Accessor’ is a ‘Getter’ that accompanies a ‘Setter’. The reason it is called an ‘Accessor’ is because it accesses the variable set using a ‘Setter’.
So what does that mean for you. This error means that the Getter(Accessor) is not set as the same Type as the Setter.
Fix:
Make sure that whatever you return in the ‘Getter’ is the same ‘Type’ as what is set in the ‘Setter’.
Bad Code:
function get sClickable():String {
return _clickable.toString();
}
function set sClickable(myClickable:Boolean):void {
this._clickable=myClickable;
}
Good Code:
public function get sClickable():Boolean {
return _clickable;
}
public function set sClickable(myClickable:Boolean):void {
this._clickable=myClickable;
}
So now you know how to solve ActionScript Error #1053.
As Always Happy Flashing.
Flash/Flex AS3 Error #1023: Stack overflow occurred.
Error #1023: Stack overflow occurred
at MyClass/get id()
Description:
This will happen if the stack has so much data that it is full. Nothing like Thanksgiving dinner to overflow my stack. What is a stack and how does it get full you ask. Simply put each method(function) has a stack and that stack stores data associated with the method such as local variables with the method. Although it is a good idea to understand what a stack is you really you don’t need to have an in depth understanding of stacks to understand this error and it’s solution. Basically this error is saying that you are most likely calling the function recursively. Or in other words you might be calling the function from within itself.
Solution:
To rid yourself of ActionScipt error 1023 make sure that you don’t call the method from within itself which will eliminate any type of recursion in your method call. You may be tempted to do this by setting a variable name the same as the function name. Change either one and this will go away. Notice in the ‘Bad Code1’ example that each time the getter returns what you think is an ‘int’ you actually are calling the setter function again recursively. The trace statement will also produce AS3 Error #1023
Bad Code1:
public function set id (myId:int):void
{
this._id = id;
}
public function get id ():int
{
trace(“this.id”,this.id);
return this.id;
}
Good Code1:
public function get id ():int
{
trace(“this.myId”,this.myId);
return this.myId;
}
Bad Code2:
private function recursiveLoop ():void
{
recursiveLoop ();
}
Good Code2:
private function noRecursion():void
{
someOtheFunction ();
}
Adobe actually has a reasonable explanation for this error in liveDocs. Here is a link to the Adobe page that explains ActionScript Error 1023
As always Happy Flashing
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 Error #2136: The SWF file file:///C|/Curtism/Flash/matchWordsGameTest.swf contains invalid data
#2136: The SWF file file:///C|/Curtism/Flash/myFile.swf contains invalid data.
Fun error that you get when compiling the swf with an external AS file as your ‘Document class’. Most Likely you will get this error if you are using a document class and also have code on your timeline.
Fix :
Remove the code from your timeline or remove the Document Class
As Always Happy Flashing
Added new info to ActionScript Error #1119
Error #1119 is a tricky little fella and has a few reasons why it will appear. I have added new and valuable info to the original post.
http://curtismorley.com/2007/06/13/flash-cs3-flex-2-as3-error-1119/
Thanks and Happy Flashing
Flash CS3 / Flex 2 Error #1084
ActionScript Error #1084: Syntax error: expecting rightbrace before end of program.
Error 1084 is the general error number for syntax errors. ActionScript Error #1084 can be any number of errors. I will keep this one up to date with all the variations I find and how to fix them.
AS3 Error 1084: Syntax error: expecting rightbrace before end of program
This is a very easy one. This error just means that you are most likely missing a right brace. Or you have nested code improperly.
Bad Code:
package com.cjm
{
class CoolClass {
function CoolClass () {
trace(“Something cool”)
}
}
Good Code:
package com.cjm
{
class CoolClass {
function CoolClass () {
trace(“Something cool”)
}
}
}
Please make note of the third bracket at the end of the good code.
ActionScript Error #1084: Syntax error: expecting colon before semicolon.
You will most likely get this error if you are using a ternary statement and you forget to use a colon, forgot the last part of your ternary, or you replace the colon with a semicolon. This is illustrated in the following example:
Bad Code:
me.myType == “keys” ? trace(keys);
or
me.myType == “keys” ? trace(keys) ; trace(defs);
Good Code:
me.myType == “keys” ? trace(keys) : trace(defs);
Flash/Flex Error #1084: Syntax error: expecting identifier before leftbrace.
Description:
This Flash/Flex Error is reported when you left out the name of your class. The ‘identifier‘ that it is looking for is the name of your class.
Fix:
You will see in the code below that you just need to add in the name of your class and the error will go away.
Bad Code:
package com.cjm.somepackage {
public class {
}
}
Good Code:
package com.cjm.somepackage {
public class MyClass {
}
}
Flex/Flash Error #1084: Syntax error: expecting leftparen before colon.
or
Flex/Flash Error #1084: Syntax error: expecting rightparen before colon.
Description:
These AS3 Errors are reported when you the order of the parenthesis and colon are not in the proper place or the parenthesis is missing.
Fix:
The AS3 code below demonstrates the placement error. Properly order the items and the error will disappear. Also, make sure that a parenthesis is not missing. The ‘Bad Code’ gives an example of leftParen and then right paren in the order.
Bad Code:
public function ScrambleSpelling:void (s:String)
or
public function ScrambleSpelling(s:String:void
Good Code:
public function ScrambleSpelling (s:String):void
Flex/Flash Error #1084: Syntax error: expecting rightparen before semicolon.
Description:
This AS3 Error is reported most often when the parenthesis is missing.
Fix:
Make sure that a parenthesis is not missing. The ‘Bad Code’ gives an example of leftParen and then right paren in the order.
Bad Code:
tempArray.push((middle.splice(middle.length-1) * Math.random());
or
tempArray.push(middle.splice(middle.length-1) * Math.random();
Good Code:
tempArray.push(middle.splice(middle.length-1) * Math.random());
Flex/Flash Error #1084: Syntax error: expecting identifier before 1084.
Description:
This AS3 Error is reported when you have begun a package, class, function/method or variable with a numeric character rather than an Alpha character, _(underscore), or $(dollar sign). In the Flash Authoring environment it won’t allow you to add numerics as the first character in an instance name or in the linkage but with code it just gives this crazy error.
Fix:
Make sure to name your package, class, function/method or variable with a Alpha character, _(underscore), or $(dollar sign).
Bad Code:
package 1084_error
{
class 1084_error {
function 1084_error () {
var 1084_error:int = 123;
}
}
}
Good Code:
package error_1084
{
class error_1084 {
function error_1084 () {
var error_1084:int = 123;
}
}
}
P.S. It is probably not a good idea to give everything the same name as in the examples above.
AS3 Error #1084 will rear it’s many heads according to the particular syntax error at the moment. I will post every variation of this error that I can find.
Once again Happy Flashing
Flash CS3 / Flex 2 Error #5001
ActionScript Error #5001: The name of package ‘com.cjm’ does not reflect the location of this file. Please change the package definition’s name inside this file, or move the file
Description:
This ActionScript error is a very common one especially if you haven’t defined a good package and class structure. The simple answer is that you misspelled something in your package description or you saved the class in the wrong folder. (See example 1)
Another reason that you can get this error in Flash is because you have a Document Class and you have specified the classpath in the “Document class:” field and you have something different typed in your package. You might say well that is not possible. If your default classpath is defined in the AS3 setting then the file will compile and the class will work properly if you remove the classpath all together out of your package. This is not recommended because it is not good practice. Please review the example2 below.
Solution:
Check your paths in the package, class and ‘Document Class’.
Example 1
Bad Code
package com.ckm
{
}
Good Code
package com.cjm
{
}
Example 2
Good Code – Bad “Document class:” definition
package com.cjm
{
public class MyDocClass
{
public function MyDocClass()
{
}}}
Good Code – Good “Document class:” definition
package com.cjm
{
public class MyDocClass
{
public function MyDocClass()
{
}}}
And those are two ways to resolve ActionScript Error #5001
As Always – Happy Flashing
Flash CS3 / Flex 2 Error #1017
ActionScript 3 Error #1017: The definition of base class ImportedClass was not found.
Description 1
You may get this error from importing a custom class that does not have the proper package path into a parent class. Another reason you will get this error is if you forget to import the Class that the subclass is extending(see example 2).
Bad Code 1
(subClass called ImportedClass)
package
{import flash.display.MovieClip;
public class ImportedClass extends MovieClip
{
public function ImportingClass()
{
trace(“Message”);}}}Parent Class called ImportingClass
package com.cjm
{
import flash.display.MovieClip;
import ImportedClass;
public class ImportingClass extends MovieClip
{
public function ImportingClass()
{
trace(“Message”);}}}
Good Code 1
(SubClass called ImportedClass)
package com.cjm
{
import flash.display.MovieClip;
public class ImportedClass extends MovieClip
{
public function ImportingClass()
{
trace(“Message”);}}}
ImportingClasspackage com.cjm
{
import flash.display.MovieClip;
import ImportedClass;
public class ImportingClass extends MovieClip
{
public function ImportingClass()
{
trace(“Message”);}}}
Bad Code 2
package com.cjm
{
//import flash.display.MovieClip;
public class ImportedClass extends MovieClip
{
public function ImportingClass()
{
trace(“Message”);}}}
Good Code 2
package com.cjm
{
import flash.display.MovieClip;
public class ImportedClass extends MovieClip
{
public function ImportingClass()
{
trace(“Message”);}}}
Description 2
ActionScript Error #1017: The definition of base class MovieClip was not found.
This ActionScript Error is due to forgetting to import the MovieClip (or any other referenced class).
Bad Code 3
package com.cjm.sound
{
public class SoundControl extends MovieClip
Good Code 3
package com.cjm.sound
{
import flash.display.MovieClip;
public class SoundControl extends MovieClip
As always – Happy Flashing