Flash Action Script Error Repository

A library of solutions to Actionscript, Flash, Flex and AIR

Archive for July, 2008

The project description file (.project) for ‘MyFlexProject’ is missing

The project description file (.project) for ‘MyFlexProject’ is missing. This file contains important information about the project. The project will not function properly until this file is restored.

This error appeared when I copied my Flex project from a PC to a Mac computer. The first thing to do is look to see if the file is really there or not. In the Finder (a rough equivalent of Windows Explorer) the project directory is not showing any .project file.

Incorrect:
I copied all the flex projects (folders) from my old workspace on my pc and placed them in a new directory on my mac. Then I changed the workspace in Flex Builder 3 to point to that new folder.

Correct:
Method 1
I should have copied all the flex projects (folders) from my old workspace on my pc and placed them in a new directory on my mac. Then in Flex Builder 3 goto File > Import > Other > General > Existing Projects into Workspace > Root folder that contains the flex projects.

Method 2
If I have a single project then export that project as a Flex Archive (only available in Flex Builder 3 or greater). Then in Flex Builder 3 on the second computer goto File > Import > Flex Archive and point to the file.

No comments

Warning: 3596: Duplicate variable definition.

Message
Warning: 3596: Duplicate variable definition.


Adobe Documentation - link

NA

Curtis Morley - link

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:

Actionscript:
  1. var myArray1:Array = ["a","b","c","d","e"];
  2. var myArray2:Array = [myArray1];
  3.  
  4. //This first loop goes through the parent array
  5. for (var i:int=0; i <myArray2.length; i++) {
  6.  //this second loop iterates through the nested array
  7.  for (var i:int=0; i <myArray1.length; i++) {
  8.   trace(myArray2[i][i]);
  9.  }
  10. }

Good Code:

Actionscript:
  1. var myArray1:Array = ["a","b","c","d","e"];
  2. var myArray2:Array = [myArray1];
  3.  
  4. //This first loop goes through the parent array
  5. for (var i:int=0; i <myArray2.length; i++) {
  6.   //this second loop iterates through the nested array
  7.   for (var j:int=0; j <myArray1.length; j++) {
  8.    trace(myArray2[i][j]);
  9.   }
  10. }

or

Actionscript:
  1. var keys:String = "Word";
  2.  
  3. for (var i:int=0; i <keys.length; i++) {
  4.  //Code
  5. }
  6.  
  7. for (i=0; i <keys.length; i++) {
  8.  //More Code
  9. }

7 comments

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

Message
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


Adobe Documentation - link

NA

Curtis Morley - link

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

Actionscript:
  1. package com.ckm
  2. {
  3.  
  4. }

Good Code

Actionscript:
  1. package com.cjm
  2. {
  3.  
  4. }

Example 2

Good Code - Bad "Document class:" definition

Actionscript:
  1. package com.cjm
  2. {
  3. public class MyDocClass
  4. {
  5. public function MyDocClass()
  6. {
  7. }}}

Flash Document Class Path Bad Example

Good Code - Good "Document class:" definition

Actionscript:
  1. package com.cjm
  2. {
  3. public class MyDocClass
  4. {
  5. public function MyDocClass()
  6. {
  7. }}}

Flash Document Class Path

And those are two ways to resolve ActionScript Error #5001

12 comments

ActionScript Error #5000: The class ‘com.cjm.MyObj’ must subclass ‘flash.display.MovieClip’ since it is linked to a library symbol of that type.

Description:
This little error will pop up when you have used the linkage in your library and have not targeted the Class properly.

Fix:
Make sure that in your custom ActionScript Class that you have imported the MovieClip Class properly.

Bad Example:

Actionscript:
  1. package com.cjm{
  2.     public class MyObj extends MovieClip {

Good Example:

Actionscript:
  1. package com.cjm
  2.     {
  3.     import flash.display.MovieClip
  4.     public class MyObj extends MovieClip {

So import those classes properly to fix ActionScript Error #5000 and Happy Flashing

1 comment

3553: Function value used where type void was expected. Possibly the parentheses () are missing after this function reference.

Description:
This is one of the best descriptions that I have seen for a Flash Error. This Flex/Flash Error is actually just a Flex/ Flash Warning. This error/warning means exactly what it says. You just forgot the parentheses () when you tried to make a method call.

Fix:
Add the Parenthesis

Bad Code:

Actionscript:
  1. var myTime:Timer = new Timer(1000, 3);
  2.     myTime.start;

or

Actionscript:
  1. var myDate:Date = new Date();
  2.     myDate.getDate;

Good Code:

Actionscript:
  1. var myTime:Timer = new Timer(1000, 3);
  2.     myTime.start();

or

Actionscript:
  1. var myDate:Date = new Date();
  2.     myDate.getDate();

1 comment

ActionScript Warning: 3551:

ActionScript Warning: 3551: Appending text to a TextField using += is many times slower than using the TextField.appendText() method.

ActionScript Error Description:
I love this ActionScript Warning. This is not technically an ActionScript Error instead it is a warning that helps you code better. It is very clear and easily deciphered. This states that you should not use the old way to add text to a text field but rather use the new TextField.appendText() method. This improves performance dramatically and will prevent the user from getting the 15 sec. timeout. (Error #1502: A script has executed for longer than the default timeout period of 15 seconds.)

Fix:
Use TextField.appendText() instead of +=.

Bad Code:

Actionscript:
  1. var something:String = "Happy ";
  2.     var somethingElse:String = "Birthday";
  3.     myTF_txt.text = something;
  4.     myTF_txt.text += somethingElse;

Good Code:

Actionscript:
  1. var something:String = "Happy ";
  2.     var somethingElse:String = "Birthday";
  3.     myTF_txt.text = something;
  4.     myTF_txt.appendText(somethingElse);

No comments

ActionScript Warning #1100

Warning: 1100: Assignment within conditional. Did you mean == instead of =?

Description:
AS3 warning 1100 is Adobe watching out for you and helping you out. Flash/Flex let's you know that you are assigning a variable while at the same time evaluating to see if it is true. This AS3 warning is quite easy to understand and well written.

Fix:
To solve Flex/Flash Warning 1100 all you need to do is add another " = " sign inside your conditional making 2 == rather than just one.

Bad Code 1:

Actionscript:
  1. if (topFive[i]="one") {

Good Code 1:

Actionscript:
  1. if (topFive[i]=="one") {

No comments

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:

Actionscript:
  1. var TargetDate:Date = new Date(_year, _month, _date, _hour, _minute=null);
  2.  
  3.     or
  4.  
  5.     var TargetDate:Date = new Date(_year, _month, _date, _hour, _minute="10");
  6.  
  7.     or
  8.  
  9.     var TargetDate:Date = new Date(_year, _month, _date, _hour, _minute=false);

Good Code :

Actionscript:
  1. 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.

Actionscript:
  1. var TargetDate:Date = new Date(_year, _month, _date, false, "10");

2 comments