6 Replies Latest reply on Mar 29, 2010 12:17 PM by jsd99

    Can't import class from SWC

    jsd99 Level 3

      I have created a swc file.  I can import most of the classes from it in my project, no problem.  One class, though, simply won't import.  I've tried copying the swc directly into the project, referring to the source folder of it, etc.  No dice.  The swc builds just fine so there's no error in the class.  The first few lines of the class look like this:

       

      package com.thismoment
      {
          import flash.events.Event;
          public class TakeEvent extends Event    {

       

       

      I should be able to do import com.thismoment.TakeEvent; right?  It doesn't work.  I keep getting "1046: Type was not found or was not a compile-time constant: TakeEvent."

       

      How do I find out what's going on?  Is there a way to dump out all the classes in a swc?

        • 1. Re: Can't import class from SWC
          Jason San Jose Adobe Employee

          In package explorer you can expand the SWC under the "Referenced Libraries" node. That will show you the classes in the SWC (except any that or overridden by other SWCs in the library path).

           

          A few more things to check:

           

          - Is build automatically on? Try cleaning the library project?

          - Is the class selected in the project properties > flex library build path > classes tab?

           

          Jason San Jose

          Software Engineer, Flash Builder

          • 2. Re: Can't import class from SWC
            jsd99 Level 3

            Jason San Jose wrote:

             

            In package explorer you can expand the SWC under the "Referenced Libraries" node. That will show you the classes in the SWC (except any that or overridden by other SWCs in the library path).

             

            A few more things to check:

             

            - Is build automatically on? Try cleaning the library project?

            - Is the class selected in the project properties > flex library build path > classes tab?

             

            Jason San Jose

            Software Engineer, Flash Builder

             

            What is "package explorer"?  I can't find a reference to it in the documentation.  I'm using Flex Builder 3 on Mac OS X if it matters.

             

            Build automatically is on.  I've cleaned every project multiple times.

             

            I don't have a Flex Library Build Path -> Classes tab.  I have a "Flex Build Path" entry in Project Properties, and on the Library Path it shows my library added to Build path libraries, link type: merged into code.

            • 3. Re: Can't import class from SWC
              Jason San Jose Adobe Employee

              Oops, Package Explorer is a view in Flash Builder 4.

               

              The "Flex Library Build Path" is a property page in the library project of your SWC, not of the project using the SWC. I assumed you were using a Flex Library Project in Flex Builder to create the SWC.

               

              Jason San Jose

              Software Engineer, Flash Builder

              • 4. Re: Can't import class from SWC
                jsd99 Level 3

                I have downloaded the trial of Flash Builder 4 and imported my project and library project.  Same error.  Maybe this screenshot will help you?  Let me know what other information I can provide.  It's driving me crazy!

                 

                FWIW, the errors disappear if I move the TakeEvent.as file into the project.  Obviously this isn't a tenable long term solution though.

                Screen shot 2010-03-29 at 10.05.37 AM.png

                • 5. Re: Can't import class from SWC
                  Jason San Jose Adobe Employee

                  Sorry if this is repetitive, but did you confirm that the class is visible outside the SWC? In the project "thismoment" go to your Flex Library Build Path settings and make sure either "Include all..." is selected or that "TakeEvent" is selected in the tree.

                   

                  See attached screenshot.

                   

                  Jason San Jose

                  Software Engineer, Flash Builder

                  • 6. Re: Can't import class from SWC
                    jsd99 Level 3

                    Ah, I see what you are referring to.  I didn't realize you could turn off individual classes within a library like that.  How odd.  Sure enough, that was the problem.  Apparently when you drag a file into a library project, it doesn't automatically tick the checkbox to include it in the compiled swc.

                     

                    Thanks for your help.