15 Replies Latest reply on Feb 23, 2007 2:15 PM by Newsgroup_User

    Madness with custom classes

      Hi all,

      The strangest Flash behavior is driving me near to utter madness. I am working on an application with a few custom classes. Everything worked fine for many weeks. Yesterday, I quit Flash, and upon reopening my FLA, none of the custom classes would link in. I got the error "The class or interface <xxx> could not be found."

      After hours of banging my head, I tried something simple. I created a new .fla called test.fla. I created a layer called Actionscript. I added the following code to the first frame of the Actionscript layer:

      var test:ImportTest = new ImportTest();

      I then, in the exact same directory as the file test.fla, created a file called ImportTest.as. This file has the following contents:

      class ImportTest {
      public function ImportTest() {

      When I execute this test.fla, I get the error:

      **Error** Scene=Scene 1, layer=Actionscript, frame=1:Line 1: The class or interface 'ImportTest' could not be loaded.
      var test:ImportTest = new ImportTest();

      Total ActionScript Errors: 1 Reported Errors: 1

      What gives? Perhaps a classpath issue? Well, my global classpath has:


      The dot alone should be enough.

      My document classpath has:

      Perhaps it's a permissions problem? Doubtful. The directory listing is:
      -rw-r--r-- 1 Richard Richard 85 Feb 22 14:35 ImportTest.as
      -rw-r--r-- 1 Richard Richard 41472 Feb 23 09:47 test.fla

      I'm using Actionscript 2.0 in Flash 8 on a Mac OS X 10.4.

      Like I said, this all worked perfectly well just moments before. I quit Flash to install some Mac OS X updates (the sorts of standard updates that Apple pushes out from time to time - in this case they were updates to support changes in Daylight Savings Time), restarted the computer, opened Flash, and I can no longer seem to include any external actionscript files.

      Any ideas? I am at the end of my rope on this one, ready to jump off a bridge!! I've attached the code for your reference....

        • 1. Re: Madness with custom classes
          rj_resnick Level 1
          Sorry, I realized only after submitting that I can't attach the FLA to the post. It's truly as simple as I mentioned it was above. Just one line of code trying to instantiate a variable called test of type ImportTest, which is defined externally in the same directory.

          Something else I omitted: it's Flash 8 Professional.

          • 2. Re: Madness with custom classes
            SymTsb Level 2
            have you tried to include code?

            #include ImportTest.as

            var test:ImportTest = new ImportTest();
            • 3. Re: Madness with custom classes
              rj_resnick Level 1
              Yes, however I'm using Actionscript 2.0 so if I add the line

              #include "ImportTest.as"
              var test:ImportTest = new ImportTest();

              I get the error message:
              **Error** /Users/Richard/Documents/Flash/End of Oil/ImportTest.as: Line 1: Classes may only be defined in external ActionScript 2.0 class scripts.
              class ImportTest {

              I have also tried explicitly importing the class, e.g.:
              import ImportTest;
              var test:ImportTest = new ImportTest();

              I get the good 'ole:
              **Error** Scene=Scene 1, layer=Actionscript, frame=1:Line 2: The class or interface 'ImportTest' could not be loaded.

              This seems like something major is broken, as I have built the most degenerate case ever. A simple FLA with a sample external AS, both in the same directory. All this used to work. Quitting Flash, installing some OS updates, and restarting Flash and now I'm left with what seems to be an inoperable Flash 8 Professional.

              Other thoughts?

              • 4. Re: Madness with custom classes
                rj_resnick Level 1
                Could this be an issue with spaces in classpath directory names? When "." is expanded, how does it interpolate spaces?

                At wit's end..
                • 5. Re: Madness with custom classes
                  rj_resnick Level 1
                  Ok, I've truly and completely solved the problem and will post the crazed answer for anyone who ever finds themselves in such a terrible situation again.

                  In the application directory I had:
                  dataprocessing/<lots of different files not used directly by flash>

                  Of great importance is that in this directory there are TWO subdirectories: oil/ and dataprocessing/. One of them is actually a package of classes. The other is just a plain old subdirectory with file droppings.

                  The code:
                  import oil.Simulator.*;
                  var world:World = new World();

                  FAILS TO FIND the oil.Simulator.World class if the dataprocessing/ folder is there.

                  Removing the dataprocessing/ folder fixes the problem.

                  It seems that imports do not work (nor does a direct full path reference to the class in question, e.g., var world:oil.Simulator.World;) if there are other directories in your "." directory that are NOT packages.

                  I have been able to find no documentation on this in the Flash docs. Seems like a bug. I could be wrong.

                  Totally frustrated, but thank goodness the problem is solved. I definitely feel like I've wasted a lot of time on an issue that should not be an issue. Maybe Adobe is listening.
                  • 6. Re: Madness with custom classes
                    Peter Lorent Level 2
                    Odd. Tested this and I don't run into any problems.
                    In my global classpath I have:
                    • 7. Re: Madness with custom classes
                      rj_resnick Level 1
                      Very strange, isn't it? Are you on a Mac? OS 10.4?

                      There's definitely some sort of a bug which seems system dependent in some way. It might be architecture, it might be other software, it might be the amount of rum I had in my coke last night (clearly not enough!) but I can reproduce this on my system.

                      Oh well... a fixed problem isn't a problem.

                      • 8. Re: Madness with custom classes
                        Peter Lorent Level 2
                        Yes, I am. And I also updated recently like you did. So basically we are on the same platform.
                        Even if I use the import statement (which doesn't import anything btw) to import the directory that is not a package, I don't get any errors...
                        I can't replicate the error here...
                        • 9. Re: Madness with custom classes
                          rj_resnick Level 1
                          It may actually not be a general issue with another directory inside of the FLA directory besides package dirs. It could actually be the contents of the dataprocessing dir itself.

                          The only way to figure out exactly what the problem might be inside that directory would be to take out one file at a time and try again and again. That makes me shiver. There are thousands of files in there.
                          • 10. Re: Madness with custom classes
                            Level 7
                            Seems like normal behavior to me. Flash has never parsed folders inside
                            class path's before.

                            import com.blurredistinction.*;

                            will import classes in the com/blurredistinction folder only - not
                            subfolders within it. You need to explicitly reference them if you want to
                            import from them.

                            Same when you define a class path in preferences - you can just import all
                            your classes from any folders within your class path - you need to explicity
                            import from each 'package' (folder).

                            This is definitely not any kind of bug.

                            Dave -
                            Head Developer
                            Adobe Community Expert

                            • 11. Re: Madness with custom classes
                              rj_resnick Level 1
                              Thanks Dave for the comment. I think you missed the question though... the understand completely your point and wasn't confused about that.

                              The issue is that the dataprocessing dir is not a package. It's just another folder in the same directory that a top level package folder exists in. If the dataprocessing directory is there, the package (oil.whatever.*) is not loadable into the fla. If I remove the data processing folder, which again, just contains lots of file droppings, the oil.*.* packages are importable.

                              That *does* seem like a bug to me.
                              • 12. Re: Madness with custom classes
                                Level 7
                                Hmmm, I may have missed the point before - but I still do. First off, a
                                'package' and a 'folder' are one and the same - a 'package' is just a folder
                                that contains classes, usually relevant to some project, or one another.
                                From what I read in your message you have:


                                and within your myFile.fla you have:

                                var sc = new SomeClass();

                                it fails? Or at least it fails until you remove the dataprocessing folder...
                                is that right? If that's so then it makes no sense to me.

                                I just tested this using my c:\jobs folder, which is a folder containing a
                                bunch of different jobs - none of which is defined as a classPath in Flash.

                                In Flash I made test.fla - it contains this code on frame 1:

                                var a:Taco = new Taco();

                                I saved it in the c:\jobs folder as test.fla

                                In that same folder I made Taco.as, which contains:

                                class Taco
                                function Taco()
                                trace("taco instantiated");

                                Also in the jobs folder is about 50 other folders, so I have something like


                                Runs without issue - even with a folder named 'dataprocessing' within the
                                jobs folder.

                                Maybe I still don't understand your problem?

                                Dave -
                                Head Developer
                                Adobe Community Expert

                                • 13. Re: Madness with custom classes
                                  rj_resnick Level 1
                                  No... you got it perfectly. That's my problem. Definitely seems OUT OF CONTROL weird but I can confirm and reproduce this on my Mac OS 10.4, over and over and over again.

                                  This must be a bug, I can't explain it otherwise.

                                  The only other thought is that it's not the existence of the dataprocessing folder that is causing the problem, but rather something inside of it. But still, since I never ever ever try a:

                                  var dumbIdea:dataprocessing.blabla;

                                  or a

                                  import dataprocessing.*;

                                  Flash should just totally ignore that directory. It ain't a package and I never refer to it as such.

                                  It's the weirdest, strangest, most ridiculous thing I've seen in a long time. It took two days and great pain to solve. And the solution - to get that dataprocessing directory out of the main top level application development directory - is rather annoying. Workable, but leaves one with a lower trust-value in Flash 8 Pro.


                                  Thanks for all of the comments.

                                  • 14. Re: Madness with custom classes
                                    rj_resnick Level 1
                                    (addendum: I understand that packages and folders are equivalent... when I say "not a package, but rather a folder" I mean that there are no classes in the folder and I never treat the folder like a package from within Flash 8 Actionscript. Sorry for the confusion.)

                                    (second addendum: it is terribly frustrating that no one else can reproduce this, since whether it's a bug or not, it'll never get fixed unless it can happen over and over.)

                                    (third addendum: again, thanks a zillion for all of your thoughts and help.)
                                    • 15. Re: Madness with custom classes
                                      Level 7
                                      I got it? Really. Wow... that is odd stuff then. Sorry that I can't repro it
                                      To your addendum - glad you got the 'distinction' of folders vs packages.
                                      Just making sure we're on the same wavelength is all. And, I understand the
                                      frustration, believe me.
                                      Have you tried emptying your \dataprocessing folder to see if it is in fact
                                      something within it? Mine was empty, and caused no problem.
                                      Maybe try resetting your class paths to the Flash defaults? Might it be
                                      somehow that the folder you are in won't get looked at for as files? Though
                                      that makes no sense. Have you tried moving that .as into one of your class
                                      path folders to see if it fixes it? Tried renaming it?
                                      I must say, you seem pretty competent at sleuthing this out though, so I'm
                                      not sure what to tell you. Hopefully someone will read this that has had,
                                      and fixed, this problem.

                                      Dave -
                                      Head Developer
                                      Adobe Community Expert