Copy link to clipboard
Copied
I've been working on my second game for several weeks now and am just starting to round the corner and the finish line is in sight.
Unfortunately, this is when everything seems to be falling apart.
Now when I run my program, sometimes it works fine, sometimes it gives me errors. It's not that I'm changing anything, I've tested it a few times in a row and sometimes I get 1 error, sometimes I get 5, sometimes it runs great.
The errors include:
"
/Documents/Flash_Projects/PotN/bgImage.as, Line 11 | 1021: Duplicate function definition. |
//On an empty class that is only defined and added to the stage in main.as
and
/Documents/Flash_Projects/PotN/spark.as, Line 1 | 5000: The class 'spark' must subclass 'flash.display.MovieClip' since it is linked to a library symbol of that type. |
//On various game elements that have been working fine up until now, and continue to work fine sometimes.
One thing that is interesting is that in my library, the properties for my MovieClips contain an empty base class. When I try to edit it to say "flash.display.MovieClip," flash tells me it is a native class and will be defined at runtime. That seems irregular to me, but I am obviously still very, very new to all of this.
So that's my problem. I haven't posted any code yet because I wouldn't even know where to start. Any ideas or thoughts are very much appreciated, thank you!
What is on line 11 of bgImage.as?
I think your other error will go away on its own when you fix the first error. If not, it means that you have external code on a path that Flash isn't finding where it expects it.
Note that standard coding convention for ActionScript is to start Class names with a capital letter. For example BgImage.as and Spark.as. You may also want to try setting the Base Classes to the AS Class you're using rather than the Class.
Copy link to clipboard
Copied
What is on line 11 of bgImage.as?
I think your other error will go away on its own when you fix the first error. If not, it means that you have external code on a path that Flash isn't finding where it expects it.
Note that standard coding convention for ActionScript is to start Class names with a capital letter. For example BgImage.as and Spark.as. You may also want to try setting the Base Classes to the AS Class you're using rather than the Class.
Copy link to clipboard
Copied
line 11 of BgImage.as (which I updated the name, along with all other classes) was the constructor function for BgImage. It was only,
public function BgImage {
}
I believe, thanks to you, I found my problem. Although I do not understand it entirely, I think I have a very elementary grasp as to what happened.
I wanted to add a preloader to the game, so I found a tutorial online that did so by unchecking "export in first frame." So without fully finishing the tutorial or understanding what I was doing, I unchecked those boxes in all of my classes.
I am assuming what happened was that when I unchecked those boxes, my code was executed before any class was exported, so flash never could find them. Although it's not exactly the error message I would expect to get, it makes some sense. Of course there's a very good chance my guess it completely off base.
Thank you very much Amy, your advice gave me a chance to take a step backward and assess the entire problem.
Copy link to clipboard
Copied
I wonder if your function is literally
public function BgImage {
}
and not
public function BgImage() {
}
?
I wouldn't think that would compile without an error or warning.
Regardless, you're right that this whole thing isn't well explained.
So, here's my take on it:
When you have the "export on Frame N" checked, that means that all the Classes that have that box checked will be compiled right before the frame that you've specified. If you have frame 1 specified, then every Class with that box checked has to load before the movie can begin playing. This is one reason I use the timeline and don't instantiate anything visual through code but popups. It's also why I usually code to interfaces--the main Document Class doesn't have a direct connection to most of the Classes used on the timeline.
However, if you choose to instantiate a library symbol in your main Document Class, then the timeline must have advanced past the point where the symbol is compiled before you can use it. This is why so many Flash movies even have preloaders--because they instantiate everything through code, so everything must be loaded before you can show anything. Kind of a shame, but that's how most people code.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now