2 Replies Latest reply on May 25, 2008 3:46 PM by puponpup

    "The class being compiled does not match the class that was imported"

    puponpup
      ----------Actions on timeline in sixSpices/updateSite/updateSite.fla----------

      import com.sixspices.updater.view.*;
      var calDrawer:CalendarView = new CalendarView(); //Listener / view

      ----------sixSpices/com/sixspices/updater/view/CalendarView.as file----------

      class CalendarView {
      public function CalendarView(){
      }
      public function onRecieveData(listOfEvents:Array) {
      displayEvents(listOfEvents);
      }
      public function displayEvents(listOfEvents:Array):Void {
      trace(listOfEvents);
      }
      }

      When I test the movie (updateSite.swf) in flash, it gives me the error:
      The class being compiled, 'CalendarView', does not match the class that was imported, 'com.sixspices.updater.view.CalendarView'.
        • 1. Re: "The class being compiled does not match the class that was imported"
          puponpup Level 1
          Here is my file structure:

          sixSpices
          -->updateSite
          -->-->updateSite.fla
          -->-->updateSite.swf
          -->com
          -->-->sixSpices
          -->-->-->updater
          -->-->-->-->view
          -->-->-->-->-->Calendar.as

          If I move updateSite.fla to the folder sixSpices so that "com" is in the same folder as it, I get the same error.

          The following works with no problems (no similar error):

          ----------Actions on timeline in sixSpices/updateSite/updateSite.fla----------

          import com.sixspices.updater.model.*;
          var calModel:CalendarOverview = new CalendarOverview(); //Broadcaster / model

          ----------sixSpices/com/sixspices/updater/model/CalendarOverview.as file----------

          import com.sixspices.updater.model.*;
          import mx.utils.Delegate;
          import mx.events.EventDispatcher;

          class CalendarOverview {
          //...
          public function CalendarOverview(){
          //...
          }
          //...
          }
          • 2. "The class being compiled does not match the class that was imported"
            puponpup Level 1
            I figured it out (with a little help from further google searching). I had to import the package "import com.sixspices.updater.view.*;" in the CalendarView file. I thought that would be counterintuitive since it's not using itself - it is itself - and the file structure should have denoted where it existed. However, once I did the importing, it now runs without error.

            Moral of the story:

            When using classes in multiple files they should either import the package they are contained in, or have their full name written out like:

            class com.sixspices.updater.view.CalendarView {


            Further discussion here