As3 Error 1046 Custom Class
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up AS3 Errors: 1046: & 1180: Importing custom class into mc on second frame? up vote 0 down vote favorite Pulling my hair out here trying to solve this one. I have no experience with classes...I code everybit of AS3 into the frames usually. I was trying a custom class out and it just isn't working well. I have a movieclip called mc_info_panel that I have placed onto my stage in frame one of my main timeline. One frame one of mc_info_panel i have the following AS3 code: stop(); on frame 2 of mc_info_panel I am trying to import my custom class: import com.displayObj.ImgViewer; Here are my errors codes: //-----first error code----- 1046: Type was not found or was not a compile-time constant:ImageContainer. this error's location & source: Symbol 'mc_info_panel', Layer 'Layer 2', Frame 2, Line 35 var imageContainer:ImageContainer; //-----second error code----- 1046: Type was not found or was not a compile-time constant:ImageContainer. this error's location & source: Symbol 'mc_info_panel', Layer 'Layer 2', Frame 2, Line 287 var imgContainer:ImageContainer=new ImageContainer(); //-----third error code----- 1180: Call to a possibly undefined method ImageContainer. this error's location & source: Symbol 'mc_info_panel', Layer 'Layer 2', Frame 2, Line 287 var imgContainer:ImageContainer=new ImageContainer(); Why are these errors coming up? Here is the class: package com.displayObj { import flash.events.*; import flash.display.MovieClip; import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.*; import flash.geom.*; //class to display a bitmap data with reflexion public class ImageContainer extends MovieClip { //bitmap object private var bmp:Bitmap; //reflection bitmap object private var reflexion:Bitmap; //ref bitmap data private var refData:BitmapData; //reflextion mask private var refmask:Sprite; public function ImageContainer() { //initialize the bmp and the reflexion object bmp=new Bitmap
what built-in AS3 classes should be imported into your custom AS3 class. To illustrate the process, we use an applet that has the same functionality as the applet in How To Load an Image at Runtime in AS3 and Display Load Progress. The difference is that in this example all the code is placed in an external AS3 class file. Download Download all the files related to this How-To: htimportas3.zip The Class File and The Answer When you open the zip package, you will see that the fla file, htimportas3.fla, has no Timeline code. http://stackoverflow.com/questions/3270106/as3-errors-1046-1180-importing-custom-class-into-mc-on-second-frame Instead, you see LoadOneImgHowTo name in the Document Class field. Indeed, the class file LoadOneImageHowTo.as appears in the same folder as the fla file. When you put your code on the Timeline, all the necessary AS3 built-in classes are automatically imported. It is not so in a custom AS3 class, a Document Class or otherwise. Here is the code in the class LoadOneImgHowTo. Plase note all the import statements following the http://www.flashandmath.com/howtos/importas3/ package wrapper. This is our focus in the present How-To. You can basically ignore the rest of the code. (For explanations of the loading process see How To Load an Image at Runtime in AS3 and Display Load Progress.) In htimportas3.fla, we created some static text and a dynamic TextField with the instance name 'infoBox'. In this field, we display messages to the user about loading. We also created on the Stage a button with the instance name 'btnLoad'. package { //Any Document Class has to extend the MovieClip class or the Sprite class. import flash.display.MovieClip; //The next two classes have to do with infoBox, //and the button, btnLoad, (both created on the Stage). //In Flash CS4, they are automatically imported. import flash.text.TextField; import flash.display.SimpleButton; //MouseEvent and all the subsequent classes //have to be imported in CS3 and CS4 alike. import flash.events.MouseEvent; //The remaining classes are necessary for our instance of the Loader //class to function. import flash.display.Loader; import flash.events.Event; import flash.events.ProgressEvent; import flash.events.IOErrorEvent; import flash.net.URLRequest; public class LoadOneImageHowTo extends MovieClip { private var loader:Loader; //The class constructor. The constructor will be //evoked automatically when the movie opens. public function LoadOneImageHowTo (){ loader =new Loader(); this.addChild(loader); loader.x=65; loader.y=50; loader.contentLoaderInfo.a
in Action Script, Flash 9 AS3 File under Adobe Flash 9 / Action Script 3 (AS3) Errors Error Message: 1046: Type was not found or was not a compile-time constant: caseStudyLink. The Problem: http://www.eddieoneverything.com/flash-9-as3/as3-error-1046-type-was-not-found-or-was-not-a-compile-time-constant.php I was getting this error message when trying to tween a MovieClip on the stage. Flash was telling me that the error message was coming from one of my package files http://rezider.com/questions/4013437/as3-error-1046-handler - in this case, it was a custom class that I was using to extend the parent MovieClip. It is notable that this class had no direct mention of the object as3 error I was trying to tween. Everything was running smoothly until I added an instance name to the existing MovieClip. The Cause: I can't say for sure why, but for some reason Flash was unable to find the object I was referring to, even though it was indeed in the Library and had the proper class name filled in. The Solution: I duplicated the as3 error 1046 offending MovieClip in the Library, then used the "swap" button in the properties pane to swap the parent object in every keyframe that the instance was being used. Presto - problem went away. Go figure. Tags: actionscript, adobe, as3, flash, programming Related PostsDisabling TextArea Scrolling in Flash AS3How to disable the HTML5 player on YouTube in Chrome browserValidating an Email Address with PHP’s filter_var isn’t perfectHow to Scan a Computer for Open PortsThe Zen of Taco Bell Programming - Using Unix Tools to Prevent Reinventing the WheelAcrobatInfo.exe is as bad as a Virus - How to remove itHow to Make phpbb3 Forum Links Automatically rel="nofollow" 23 Comments on "AS3 Error: 1046: Type was not found or was not a compile-time constant" muflyn October 27th, 2008 at 7:45 am I had the same problem and it was driving me nuts! it's a very wierd bug, but your solution works… problem solved! tks Fred November 28th, 2008 at 5:41 am I had the same problem for only ONE out of 6 clips in my library, and it happened to be one for which I had mistakenly given a L
Forgot Password? Login with FacebookLogin with Google Register I agree with terms & conditions Register Back to Login Reset Password Reset Password Return to Login Sign In Login Login Need an account? Register here! Forgot Password? Login with FacebookLogin with Google Register I agree with terms & conditions Register Back to Login Reset Password Reset Password Return to Login Buy Sell Mortgage Your search results Page not found We're sorry. Your page could not be found, But you can check our latest listings & articles Latest Listings Latest Articles Hello world! Search Recent Posts Hello world! Recent CommentsArchives September 2016 Categories Uncategorized Meta Register Log in Entries RSS Comments RSS WordPress.org Copyright © 2016 Rezider, Inc. All rights reserved. Fair Housing and Equal Opportunity. Have a Question? Visit our Help Center to find the answer. Contact Us Use the form below to contact us! Send