Error #1046: Type was not found or was not a compile-time constant: Name.
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.
AS3 Error 1046 Fix 1:
Remove the instance from the stage, change the name of the instance, or remove the Class linkage in your library.
AS3 Error 1046 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’.
Update:
AS3 Error 1046 Fix 3:
This error will also show up if you are trying to instantiate a library object with an instance name that is the same as the AS Linkage in your library. In other words, you can’t call it the same name. Look at the image for the Linkage name and then take a look at the code examples. The red code below shows that the same name is being used.
Bad Code:
var TTA:TTA = new TTA();
Good Code:
var thirdAlternative:TTA = new TTA();
And now you know three ways to resolve ActionScript Error #1046: Type was not found or was not a compile-time constant:
As always Happy Flashing!
Pingback: A Tutorial in AS3 with Flashdevelop | Precision Code
thank you, thank you , thank you!!!!!!!!!!!!
Thanks for the post! I did not import the TweenEvent class, and that fixed my issue! I really appreciate you posting this!
I have been stressing over this error for two days. Your definition/explanation is the best I’ve seen and gives me hope. Thanks!
Thanks for the comment Anne. AS3 Error #1046 can be a tricky Flash Error. Glad this helped.
Problem: Getting a 1046 error (Type was not found or was not a compile-time constant: PieChart.)
Possible soln:
Inside of the src folder, you have to put all required classes in there. for exmaple, if my PieChart class is in lib.charts, I would have to put the lib folder inside of src. Then you can use the statement to import the class:
import lib.charts.PieChart;
thanks mate your blog really does save me from hammering my head to wall..,
this time because i forgot to import the textfield dor textfield inside my movieclip.
keep up the good work mate.
This single post fixed a problem I had been wrestling with for two hours. Just wanted to say thank you!!!
This also happened to me, but because I had a Function with the same name as the LinkageID.
Thanks Curtis, each article on here is spot on and perfectly clear and explained π
I got rid of this error 1046 caused by the code below by simply removing the void statement. I can’t say why it works, but it does…
function packagedF():void{
checkSec.removeEventListener(TimerEvent.TIMER, checkerF);
rawImage = imgData.image[imgNum].imgURL;
numberOfChildren = imgData.*.length();
rawW = imgData.image[imgNum].imgW;
rawH = imgData.image[imgNum].imgH;
title_txt.text = imgData.image[imgNum].imgTitle;
imageLoader = new Loader;
imageLoader.load(new URLRequest(rawImage));
master_mc.addChild(imageLoader);
imageLoader.x = (stage.stageWidth – Number(rawW)) /2;
imageLoader.y = (stage.stageHeight -50 – Number(rawH)) /2;
}
Thanks a lot Curtis…
had a problem with with my site that im building
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at About$iinit()
was solved my method FIX 2..importing a class and initializing it with the code
public function About() // this function ensures that when the website is added to stage the Website() class is called
{
this.addEventListener(Event.ADDED_TO_STAGE, init);
}
public function init(e:Event):void
{
…..
}
Hi, I’m relatively new to actionscript, and I’ve been getting this error when linking my .as file to my .fla. I’m using this tutorial.
http://asgamer.com/2009/as3-character-movement-helicopter-games/comment-page-1#comment-4542
I changed it around a bit because I wanted it to be like a straight shooter and not like a helicopter, but that’s pretty much just the physics, not the linking.
Upon compiling, the fla throws the 1046 error for the line Helicopter(stageRef:Stage):void{
and says “Type was not found or was a compile-time constant: Stage”
At first I thought that it was because I had named the instance name for my ship “Ship”, same as my class in the .as file, but after changing the class name the error persisted.
The thing I find puzzling is the stageRef variable. It seems to work, but can’t be accessed in the Helicopter function…
Maybe I’m just doing something stupid?
I get this error whenever i try to use a timer
Heres my code:
package{
import flash.display.*;
import flash.events.*;
import flash.ui.*;
public class Main extends MovieClip{
public var obj:String;
public var mytimer:Timer;
public function Main(){
ShowButtons();
_Back.addEventListener(MouseEvent.CLICK, BackClick);
_Collar.addEventListener(MouseEvent.CLICK, CollarClick);
_Office.addEventListener(MouseEvent.CLICK, OfficeClick);
}
public function ChangeBG(obj:String):void{
_Change_BG._BG.gotoAndStop(obj);
_Change_BG.play();
}
public function ShowButtons():void{
_Collar.gotoAndPlay(2);
_Office.gotoAndPlay(2);
}
public function HideButtons():void{
_Collar.gotoAndPlay(17);
_Office.gotoAndPlay(17);
}
public function BackClick(event:MouseEvent):void{
_Change_BG.play();
ShowButtons();
}
public function CollarClick(event:MouseEvent):void{
HideButtons();
_Collar._Collar_Inner.gotoAndStop(31);
_Collar._Collar_Inner_2.gotoAndStop(31);
ChangeBG(“Collar”);
}
public function OfficeClick(event:MouseEvent):void{
HideButtons();
_Office._Office_Inner.gotoAndStop(31);
_Office._Office_Inner_2.gotoAndStop(31);
ChangeBG(“Office”);
}
}
}
Hey There,
I have also the 1046 error. But I don’t know how to fix this. I am working on a augmented reality project and I am working with flex builder 3. I have only one .as file with my code and that’s it. I don’t have a flash file with object in it so I have no idea where to look. The error is based on this line:
private function loop(e:Event):void I have also a line with this code: addEventListener(Event.ENTER_FRAME, loop); and I think it has something to do with each other. What do I miss???
Thanksss
Pingback: Re: Flash CS3 / Flex 2 AS3 Error #1046 | seventy6
Thanks again!!! Excellent tips
I just got this error on a mx:BubbleChart not being found.
In the end I tracked it down to the Flex SDK 3.3
I changed it back to SDK 3.2 and everything works now. π
Just in case anyone else had a similar problem …
Not sure what’s up with 3.3 π
Shaun
package {
import flash.display.MovieClip;
import flash.events.Event;
public class Engine extends MovieClip {
private var RangeHUD:RangeHUD;
public function Engine(): void {
RangeHUD = new RangeHUD(stage);
stage.addChild(RangeHUD);
}
}
}
I have the RangeHUD class.
But im getting this:
1046: Type was not found or was not a compile-time constant: RangeHUD.
Thank you so much for the Fix 1 of Error #1046!!!
THANK YOU THANK YOU THANK YOU!
The second tip helped me… and I did a little celebratory dance… cause that pretty much just made my day.
You can also get error 1046 when you use a method in a function (in a package) without first importing the class.
Like when you put this:
stage.addEventListener(MouseEvent.MOUSE_DOWN, nameFunction)
in a function, and forgot to say
import flash.events.*
I wish this helped… but all i have in the my actionscript is stop();
It worked once, and now it always gives me this error!!
I wanna rip my hear out! What else could the error be? Stuff on the stage? in the library?
Please help!!
“Tricky said,
November 15, 2007 at 2:58 pm
Donβt forget to make sure youβve declared your class public ”
WIN!! Saved me quite a bit of time there, ty much.
Just wanted to say Thank You for the details on the 1046 error, it enabled me to figure out where I went wrong!
The 1046 error will also pop up if you have a class file inside a (valid) classpath and (by accident due to sloppyness) a similar class file next to your .fla or somewhere else within your classpath.. Lesson: when moving a class file to a new location always make sure to delete the old one..
Took me a couple of hours to tackle that one.. π
Thanks for this, but I think you should have the second tip first π
hey thanks!! yer first tip really helped me.
I keep getting this error when I try adding my btn code to my .as file:
btn_1.addEventListener(MouseEvent.CLICK, btnClick1);
function btnClick1(event:MouseEvent):void
{var myLoader:Loader = new Loader();
addChild(myLoader);
myLoader.load(new URLRequest(“swf1.swf”));
}
Here is my .as file:
package usababyvb
{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.*;
import fl.controls.ComboBox;
import flash.ui.ContextMenu;
import flash.ui.ContextMenuItem;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import caurina.transitions.Tweener;
public class Main extends MovieClip
{
private var file_xml:LoadingXML;
public var cat_names_array:Array=new Array();
public var products_array:Array=new Array();
private var id_cat:int=0;
private var id_prod:int=0;
private var product:Product;
public function Main()
{
addEventListener(Event.ADDED_TO_STAGE,init);
}
private function init(evt:Event):void
{
stage.frameRate=31;
initMenu();
menu_mc.y=stage.stageHeight+30;
menu_mc.prev_btn.label=’PREV’;
menu_mc.next_btn.label=’NEXT’;
menu_mc.prev_btn.useHandCursor=true;
menu_mc.next_btn.useHandCursor=true;
menu_mc.prev_btn.addEventListener(MouseEvent.MOUSE_DOWN,setPrev);
menu_mc.next_btn.addEventListener(MouseEvent.MOUSE_DOWN,setNext);
file_xml=new LoadingXML(this);
}
public function dataHasBeenStored():void
{
initCategories();
displayProduct();
resetButtonsVisible();
}
private function initCategories():void
{
for(var i:int=0;i<cat_names_array.length;i++)
{
cat_combo.addItem({label:cat_names_array[i],data:i.toString()});
}
cat_combo.addEventListener(Event.CHANGE,setItem);
}
private function setItem(evt:Event):void
{
id_cat=evt.target.selectedItem.data;
id_prod=0;
resetButtonsVisible();
product.destroy();
displayProduct();
}
private function displayProduct():void
{
menu_mc.info_txt.text=(id_prod+1)+’ / ‘+products_array[id_cat].length;
product=new Product(cat_names_array[id_cat],products_array[id_cat][id_prod].name,products_array[id_cat][id_prod].thumb,
products_array[id_cat][id_prod].price,products_array[id_cat][id_prod].image,products_array[id_cat][id_prod].des);
product.x=stage.stageWidth/2;
product.y=stage.stageHeight/2;
addChild(product);
}
private function setPrev(evt:MouseEvent):void
{
id_prod–;
menu_mc.info_txt.text=(id_prod+1)+’ / ‘+products_array[id_cat].length;
if(id_prod=products_array[id_cat].length-1)
{
evt.target.visible=false;
evt.target.parent.prev_btn.visible=true;
id_prod=products_array[id_cat].length-1;
}
else
evt.target.parent.prev_btn.visible=true;
product.destroy();
displayProduct();
}
public function resetButtonsVisible():void
{
Tweener.addTween(menu_mc,{y:stage.stageHeight+30,time:.3,transition:”linear”,onComplete:buttonsBack});
function buttonsBack():void
{
Tweener.addTween(menu_mc,{y:447,time:.3,transition:”linear”});
}
menu_mc.prev_btn.visible=false;
menu_mc.next_btn.visible=true;
}
public function resetButtonsVisibleFromProduct():void
{
Tweener.addTween(menu_mc,{y:stage.stageHeight+30,time:.3,transition:”linear”,onComplete:buttonsBack});
function buttonsBack():void
{
Tweener.addTween(menu_mc,{y:385,time:.3,transition:”linear”});
}
}
public function hideButtons():void
{
Tweener.addTween(menu_mc,{y:stage.stageHeight+30,time:.3,transition:”linear”});
}
private function initMenu():void
{
var etichetta:String=’Flash CS3 components’;
var cm:ContextMenu=new ContextMenu();
var item:ContextMenuItem=new ContextMenuItem(etichetta);
cm.hideBuiltInItems();
cm.customItems.push(item);
item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,itemHandler1);
this.contextMenu=cm;
}
private function itemHandler1(event:ContextMenuEvent):void
{
var url:String=’http://usababyvb.com/’;
var request:URLRequest=new URLRequest(url);
navigateToURL(request,’_parent’);
}
}
}
also this is the string of code i get the error on:
protected function onBLReceived(event:BuddyListEvent):void{
currentState = ‘online’;
buddiesList.dataProvider = event.buddyList.groups[0].users;
buddiesList.labelFunction = blLF;
}
hi all so i have a problem with flex3.* i load wimas3(aim’s flex/flash library) and i get an error on the BuddyListEvent ill give u the code from that package its quiet large…:
/*
Copyright (c) 2008 AOL LLC
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the AOL LCC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.aol.api.wim.events
{
import com.aol.api.wim.data.BuddyList;
import com.aol.api.wim.data.Group;
import com.aol.api.wim.data.User;
import flash.events.Event;
/**
* The
BuddyListEvent
is fired when either groups or users are* added, removed, or moved on the buddy list.
*/
public class BuddyListEvent extends Event
{
/**
* This event fires when a full buddy list is received.
*/
public static const LIST_RECEIVED:String = “buddyListReceived”;
/**
* This event is fired before a buddy is added to the buddy list.
*/
public static const BUDDY_ADDING:String = “buddyAdding”;
/**
* The value for the type property of a buddy added event object.
*/
public static const BUDDY_ADD_RESULT:String = “buddyAddResult”;
/**
* This event is fired before a buddy is removed from the buddy list.
*/
public static const BUDDY_REMOVING:String = “buddyRemoving”;
/**
* The value for the type property of a buddy removed event object.
*/
public static const BUDDY_REMOVE_RESULT:String = “buddyRemoved”;
/**
* The value for the type property of a group added event object.
*/
public static const GROUP_ADD_RESULT:String = “groupAddResult”;
/**
* The value for the type property of a group removed event object.
*/
public static const GROUP_REMOVE_RESULT:String = “groupRemoveResult”;
/**
* The buddy associated with the event. Only valid for buddy added, buddy moved, and buddy removed events.
* This is null for group events and the LIST_RECEIVED event.
*
* For the BUDDY_ADDING event, the only property that is set on the user object is the aimId.
*/
public var buddy:User;
/**
* The group associated with the event. If it is a buddy related event, it represents that buddy’s group.
* This is null for the LIST_RECEIVED event.
*/
public var group:Group;
/**
* @private
* The personal message associated with the add buddy call. Only for ICQ.
*/
public var authorizationMsg:String;
/**
* @private
* Pre-authorized to allow the new buddy to add self into his/her buddylist. Only for ICQ.
*/
public var preAuthorized:Boolean;
/**
* This property is only valid for LIST_RECEIVED events, and it represents the user’s
* entire buddy list.
*/
public var buddyList:BuddyList;
public function BuddyListEvent(type:String, buddy:User, group:Group, buddyList:BuddyList=null, bubbles:Boolean=false, cancelable:Boolean=false)
{
super(type, bubbles, cancelable);
this.buddy = buddy;
this.group = group;
this.buddyList = buddyList;
}
override public function clone():Event
{
return new BuddyListEvent(type, buddy, group, buddyList, bubbles, cancelable);
}
override public function toString():String
{
var output:String = “[BuddyListEvent.” + this.type +
” buddy=” + buddy.toString() +
“, group=” + group.toString() +
“, buddyList” + buddyList.toString() +
“]”;
return output;
}
}
}
So small an error, so simple a solution, and yet it was so elusive until this post. Awesome and thanks much!
–eric
Pingback: curtismorley.com » AS3 Error #1051: Return value must be undefined.
Hi
I have a problem in Creating Flex Component to Flash CS3,
1.I had created the Flex component in Flex, and the component is working Flex 3.
2. The same component which has been created has to work in the Flash CS3
Please let me know how to get worked in the Flash CS3
//Here is the code
package myComponents
{
// asAdvanced/myComponents/DeleteTextArea.as
import mx.controls.Button;
public class BlueButton extends Button {
public function BlueButton() {
super();
}
override protected function measure():void {
super.measure();
//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 got this error too and adding:
import flash.text.TextField;
Seemed to solve the problem when I added it to the import section of the package. I don’t remember having that error before when adding text field’s.
But it works fine now.
Pingback: Common ActionScript 3 Errors and Explanations | Jake Rutter - XHTML/CSS Developer
Pingback: curtismorley.com » Search Engine Optimization Example
Thilo,
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.
Curtis J. Morley
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 ! π
Xavier,
Check your instance names. If you are getting this accompanied with AS3 Error 1120 I highly suggest that you check your instance names and your class name in your linkage in the library.
Let me know how that works.
Thanks,
Curtis J. Morley
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.
if you have any advise whatsoever i would greatly appreciate that.
LOL. Good to hear from you Aral. Great point.
Snpilleg is iprnmoatt..or is it?
LOL, or “package _signature_” even! (’nuff said!) π
And, finally, check that you’ve spelled everything correctly in your package singature or you might get this error π
Carroll,
Comments are moderated so that I don’t get flooded with inappropriate spam. Thanks again for the very detailed comment.
Happy Flashing,
Curtis J Morley
I left a comment here yesterday with a question. Where did it go?
Carroll,
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.
Curtis J. Morley
Curtis,
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.
To add code to the Greeter class:
Type the following code into the new file:package
{
public class Greeter
{
public function sayHello():String
{
var greeting:String;
greeting = “Hello World!”;
return greeting;
}
}
}
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();
Save the file.
Continue with Publishing and testing your ActionScript application.
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.
Ernest and Stan,
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.
Thanks,
Curtis
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.
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 {
Shawn,
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.
Let me know how this works for you and as always Happy Flashing.
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
Great tip Tricky. It isn’t always obvious that by not declaring the class public that it has a default of internal.
Thanks,
Curtis J. Morley
Don’t forget to make sure you’ve declared your class public if you’re trying to access a class from outside of its package. By default flash declares classes as internal….
package
{
public class
{}
}
instead of
package
{
class
{}
}
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.
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
package {
import flash.display.MovieClip;
import mx.flash.UIMovieClip;
public class sands extends UIMovieClip
{
function sands()
{
squareAmc.visible=false;
}
public function showThink(county:MovieClip):void
{
county.visible = true;
}
}
}
in flex when i call on a button click=”idX.showThink(squareA);”
first i was getting “Implicit coercion of a value of type Class to an unrelated type flash.display:MovieClip.”
then when i changed it to “idX.showThink(squareAmc)” //instance name
i get “Access of undefined property squareAmc”
ive tried as MovieClip and ive tried changing class name for SquareA,
do i need to define instance squareAmc dynamically? if so how?
thank you in advance π