Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Guest
Feb 04, 2009 Feb 04, 2009
I am trying to create a Flash game and am at the point where I am trying to add blocks to my platform but want to do it by script so that I could tell it where to place them on the stage rather than my having to manually do it; however I keep on getting the following errors along with the associated code on mygame.as:

1046: Type was not found or was not a compile-time constant: rect2020.
var newObject:rect2020 = new rect2020();

1180: Call to a possibly undefined method rect2020.
var newObject:rect2020 = new rect2020();

I have in mygame.fla in the library a movieclip of rect2020 which is essentially a 20x20 image I had created in fireworks and imported into the library. Is there anything special I need to do? attached is my intended code:
TOPICS
ActionScript
2.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Feb 04, 2009 Feb 04, 2009
You need to assign a Class name to the item in the library. Did you do that? If not, then right click on it in the library and select the Linkage item in the menu. In the interface that appears, select the option to export for actionscript and the mc name should automatically fill in the Class field. Be sure it matches what your code is calling it (rect2020).
Translate
Advisor ,
Feb 04, 2009 Feb 04, 2009
Right click on the item in the library, select properties, click Export for ActionScript. The text in the 'Class:' field specifies the class for Flash to autogenerate that you would then be able to initiate a variable with like you have:
var newObject:rect2020 = new rect2020();

Another tip: You've posted 211 lines of code, where if i'm right, the problem was only occurring in one line. If only for your own diagnostic purposes(let alone forum readability), try to narrow down the problem to where the error is actually occurring. This way you can narrow your focus to help in diagnosing the problem. Create a new fla if it helps.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 04, 2009 Feb 04, 2009
You need to assign a Class name to the item in the library. Did you do that? If not, then right click on it in the library and select the Linkage item in the menu. In the interface that appears, select the option to export for actionscript and the mc name should automatically fill in the Class field. Be sure it matches what your code is calling it (rect2020).
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 04, 2009 Feb 04, 2009
Thanks for prompt reply. I notice when I clicked to validate class definition for "rect2020" that I got a popup message saying "A definition for this class could not be found in the classpath, so one will be automatically generated in the SWF file upon export", but when I attempt to export, I still get the following:

symbol 'gamebg3'
1046: Type was not found or was not a compile-time constant: rect2020.

I then tried to delete and re-import the rect2020.gif file and was still encountering the same problem, even after a "save and compact". I'm not sure what else I may be missing.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 05, 2009 Feb 05, 2009
LATEST
Looks like I oversaw Ned's post, but here's what I tried to do:

1. imported to library the rect2020.gif file
2. placed a rect2020.gif file onto stage
3. right-clicked placed object on stage, convert to symbol
4. gave it the name rect2020, type = Movie Clip, Export to ActionScript checked, class = rect2020, Base class = flash.display.MovieClip, then press OK
5. warning message comes up: "A definition for this class could not be found in the classpath, so one will be automatically generated in the SWF file upon export. Press OK anyways.
6. remove rect2020 from the stage seeing that one is created in library.

I still get the 1046 error when I attempt to compile. What I don't understand is when I go to the library to my new rect2020 object and double clicked onto it, I see in its property tab that it is still a bitmap and an instance of rect2020.gif. How do I make it so that it's a movie clip like one from another flash application I am trying to model after? This is driving me nuts.

Edit: it seems to work now as I may have had some redundant code somewhere.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines