1046 Type was not found or was not a compile-time constant: _.

The class used as a type declaration is either unknown or is an expression that could have different values at run time. Check that you are importing the correct class and that its package location has not changed. Also, check that the package that contains the code (not the imported class) is defined correctly (for example, make sure to use proper ActionScript 3.0 package syntax, and not ActionScript 2.0 syntax).

The error can also occur if the class being referenced is not defined in a namespace that is in use or is not defined as public:

public class Foo{}

Description:
One reason you will get this error is if you have an object on the stage with the same name as an object in your library. So if you are trying to dynamically add a movieClip from your library that has a Class name (see image below) that is the same as the name of an instance on the stage it will give you this error. What happens when you add a class name in the library is that Flash (in this case) will create a class around that object. When you have an instance on the stage that has this same name Flash doesn’t know how to handle it because the Class was not properly instantiated.

Fix 1:
Remove the instance from the stage, change the name of the instance or remove the Class linkage in your library.

Flash Error 1046: Type was not found or was not a compile-time constant:

Fix 2:

Import, Import, Import. Another common reason that you will get this error is because you have not imported everything you are including in your movieClip. For example if you are using textFields inside your movieClip you need to include the following line of code:

Good Code:

import flash.text.TextField;

By importing the TextField object the compiler now knows what to do with that textField inside your movieClip. This will eliminate another version of this error - ‘1046: Type was not found or was not a compile-time constant: TextField’.

26 Responses to 1046 Type was not found or was not a compile-time constant: _.

hey, ive been trying to get over a similar error for a day or 2 and its really frustrating.
basically i have a class for my flash file, a method showThink takes in a movieclip and sets its visible property to true.
squareA is a symbol, squareAmc is its instance

Hey, just wanted to leave a thanks for the bit above regarding the 1046 error. I am working on a collaborative project across a few offices and wasnâ€™t aware they had added graphics to the stage statically.

The bit about the compiled class not being able to share a name with something on the stage was a great help.

I created a movie clip that is nothing more than a graphic and converted it to a movie clip and tried to publish into Flex 2. I got a bunch of these 1046 errors with no source. I converted my movie clip into a flex component. Could this be causing all the errors. I got like 6:
1046: Type was not found or was not a compile-time constant: Producer.
1046: Type was not found or was not a compile-time constant: Consumer.
1046: Type was not found or was not a compile-time constant: WebService.
1046: Type was not found or was not a compile-time constant: RemoteObject.
1046: Type was not found or was not a compile-time constant: HTTPService.

None of these have anything to do with my flash and from what I can tell.. my Flex either

For some reason Flash/Flex is trying to compile these classes and is finding a conflict. It seems that the first two are custom classes that you either wrote or more likely it is from a library symbol that has a class definition and a Base Class definition (see image above).

If you are in Flash try opening the â€˜Movie Explorerâ€™ (Alt+F3 or Window >> Movie Explorer) and do a search for Consumer or Producer with all of the options set to show. If you are Flex open the â€˜File Searchâ€™ dialog (Ctrl + Shift + F) and do a search for the same terms. It may be an import from another class or something that you wouldnâ€™t think is being imported but is.

trying to script a preloader in flash 8 actionscript 3.0, tutorial that iam followin is here http://learn005.com/podcasts/flash/preloader.mp4 i have the cose just like he says but i keep getting the 1046 error this.onEnterFrame = function():Void {

Iâ€™m having the same problem as Ernest. What bugs me is that I did this preloader tutorial and was successful the first time around. The second and third time I tried it, I received the 1046 error with Void. Donâ€™t know what to do.

You may want to consider another way of writing this preloader especially if you are using AS3. ActionScript now has an event model that standardizes the way all events are handled. It is really nice even though it does add some overhead to the code. I will post a lesson here on my blog to show how to make an ActionScript 3 preloader.

I am new to ActionScript 3 and I am having problems with this exercise taken directly from the Adobe documentation for programming with ActionScript 3. I keep getting 1046 and 1083 errors. I am confused because you would think that these people would test this out before releasing it to the public. I am not sure what is missing here. I tried to use the #include statment and I got an error. I am not sure how to have the .fla file access the .as file. This package thing is a complete mystery to me and I am not sure where to go to resolve the issue. I am using a Mac if that makes a difference. Can you help me out? I have included the content from the Programming Action Script 3 that Adobe provides. It is just a few paragraphs with the code and the instructions included. It would seem to me that Adobe should pay more attention to their quality control. If the documentation is inaccurate how are we supposed to learn how to use the product?

Creating the HelloWorld project and the Greeter class
The design statement for the Hello World application said that its code should be easy to reuse. With this goal in mind, the application uses a single object-oriented class, named Greeter, which is used from within an application that you create in Flex Builder or the Flash authoring tool.

To create the Greeter class in the Flash authoring tool:
In the Flash authoring tool, select File > New.
In the New Document dialog box, select ActionScript file, and click OK.
A new ActionScript editing window is displayed.

Select File > Save. Select a folder to contain your application, name the ActionScript file Greeter.as, and then click OK.
Continue with Adding code to the Greeter class.

Adding code to the Greeter class
The Greeter class defines an object, Greeter, that you will be able to use in your HelloWorld application.

The Greeter class includes a single sayHello() method, which returns a string that says â€œHello World!â€.

Select File > Save to save this ActionScript file.
The Greeter class is now ready to be used in a Flash or Flex application.

Creating an application that uses your ActionScript code
The Greeter class that you have built defines a self-contained set of software functions, but it does not represent a complete application. To use the class, you need to create a Flash document or Flex application.

The HelloWorld application creates an new instance of the Greeter class. Hereâ€™s how to attach the Greeter class to your application.

To create an ActionScript application using the Flash authoring tool:
Select File > New.
In the New Document dialog box, select Flash Document, and click OK.
A new Flash window is displayed.

Select File > Save. Select the same folder that contains the Greeter.as class file, name the Flash document HelloWorld.fla, and click OK.
In the Flash Tools palette, select the Text tool, and drag across the Stage to define a new text field, approximately 300 pixels wide and 100 pixels high.
In the Properties window, with the text field still selected on the Stage, set the text type to Dynamic Text and type mainText as the instance name of the text field.
Click the first frame of the main timeline.
In the Actions panel, type the following script: var myGreeter:Greeter = new Greeter();
mainText.text = myGreeter.sayHello();

Publishing and testing your ActionScript application
Software development is an iterative process. You write some code, try to compile it, and edit the code until it compiles cleanly. You run the compiled application, test it to see if it fulfills the intended design, and if it doesn’t, you edit the code again until it does. The Flash and Flex Builder development environments offer a number of ways to publish, test, and debug your applications.

Here are the basic steps for testing the HelloWorld application in each environment.

To publish and test an ActionScript application using the Flash authoring tool:
Publish your application and watch for compilation errors. In the Flash authoring tool, select Control > Test Movie to compile your ActionScript code and run the HelloWorld application.
If any errors or warnings are displayed in the Output window when you test your application, fix the causes of these errors in the HelloWorld.fla or HelloWorld.as files, and then try testing the application again.
If there are no compilation errors, you will see a Flash Player window showing the Hello World application.
You have just created a simple but complete object-oriented application that uses ActionScript 3.0. Continue with Enhancing the HelloWorld application.

The issue arises because the .FLA doesnâ€™t know where the .AS is. This could either be because you havenâ€™t saved the file yet, or you havenâ€™t saved the file in the same location. I get the same two errors using the same â€œHello Worldâ€ example in the Flash/Flex docs as you when I havenâ€™t saved the file or if I save it in a separate location from the .as file. This is solved as soon as the .fla is in the same folder as the .as file. If you want the .as file to be somewhere else that works also. The only thing that you will need to do is to use an import statement and target the file correctly.

Glad that you are joining the Flash community. Thanks Carroll and Happy Flashing.

i have been trying to figure this error message for about three days. I keep getting this error message and error message 1120. which i have no clue how to fix because they seem to contradict themselves.

Thanks so much for your help here !
I followed all your advice thorroughly but could not find a way to build a tutorial project.
In the end I found out, that People with a Flexbuilder can simply click on:
PROJECT – CLEAN UP – ALL PROJECTS,
and many error messages and also this Eror was gone !!!
Next time before panicing, try this feature – it might sve you hours ! ;-)

Great place to put this comment. This is thing that everyone should do before manual removal of hair. Sometimes the Eclipse framework gets hung up and you have to CLEAN the project before everything will build properly. Thanks for posting this comment. I know it will help many.

//Specifies the default height and width of the component, in pixels
measuredWidth=200;
measuredHeight=80;

//Specifies the default minimum height and minimum width of the component,
// in pixels. Flex cannot set the size of a component smaller than
// its specified minimum size.
measuredMinWidth=500;
measuredMinHeight=25;

i get the compailer error saying “1137:Incorect number of arguments etc.”

Now when i delete the “Bob” from pharentesis it does what it seems it should write the “Hello World!” and it works but in the adobe’s help it says:”If there are no compilation errors, you will see a Flash Player window showing the Hello World application. The “Hello, Bob” text is displayed.”

My question is, what do i need to do, to make it write HELLO BOB rather then HELLO WORLD and not get the 1137 error?

import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.*;
import flash.geom.Matrix;
import flash.events.Event;
import flash.display.GraphicsBitmapFill;
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.GraphicsBitmapFill;
stop();
/* Stop at This Frame
The Flash timeline will stop/pause at the frame where you insert this code.
Can also be used to stop/pause the timeline of movieclips.
*/

/* Click to Position an Object
Moves the specified symbol instance to the x-coordinate and y-coordinate you specify.

Instructions:
1. Replace the value 200 with the x-coordinate
where you want to position the object.
2. Replace the value 100 with the y-coordinate where you want to position the object.
*/

/* Mouse Click Event
Clicking on the specified symbol instance executes a function in which you can add your own custom code.

Instructions:
1. Add your custom code on a new line after the line that says “// Start your custom code” below.
The code will execute when the symbol instance is clicked.
*/
am getting error
Scene 1 1046: Type was not found or was not a compile-time constant: sheet1.
Scene 1 1046: Type was not found or was not a compile-time constant: tex_mc.

import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.*;
import flash.geom.Matrix;
import flash.events.Event;
import flash.display.GraphicsBitmapFill;
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.GraphicsBitmapFill;
stop();
/* Stop at This Frame
The Flash timeline will stop/pause at the frame where you insert this code.
Can also be used to stop/pause the timeline of movieclips.
*/
/* Click to Position an Object
Moves the specified symbol instance to the x-coordinate and y-coordinate you specify.
Instructions:
1. Replace the value 200 with the x-coordinate
where you want to position the object.
2. Replace the value 100 with the y-coordinate where you want to position the object.
*/
/* Mouse Click Event
Clicking on the specified symbol instance executes a function in which you can add your own custom code.
Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
The code will execute when the symbol instance is clicked.
*/
am getting error
Scene 1 1046: Type was not found or was not a compile-time constant: sheet1.
Scene 1 1046: Type was not found or was not a compile-time constant: tex_mc.
Object(this).tex_mc.addEventListener(MouseEvent.CLICK,fl_MouseClickHandler);
function fl_MouseClickHandler(event:MouseEvent):void
{
Sprite; var pic:Bitmap; // a Bitmap (reference or instantiate yourself)
var bmd:BitmapData=pic.bitmapData; //get BitmapData from Bitmap
var bg:Sprite=new Sprite();
bg.graphics.clear(); bg.graphics.beginBitmapFill(bmd);
bg.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
addChild(bg);
}
can anyone help please