0 Replies Latest reply on Dec 18, 2010 8:18 AM by userben

    how to import classes from an external actionscript file

    userben

      This is driving me crazy, I've been trying to resolve this on my own for ages, and I've reviewed a lot of different materials, but I still can't seem to just import some external actionscript classes correctly.

       

      I'm using Flash Builder 4 with the Flex 4 SDK on mac osx 10.6

       

      the class I'm trying to import (I'll call it DesiredClass) is in a folder like this

       

      /libraries/com/foreignproject/com/foreignproject/DesiredClass.as

       

      within the class itself, the package declaration looks like this (I left all the guts out for clarity):

       

       

      ---------------------------------------------------------------------

       

      package com.foreignproject

      {

          import flash.display.Sprite;


          public class DesiredClass extends Sprite

          {

              public function DesiredClass()

              {

              }

          }

      }

       

      ---------------------------------------------------------------------

       

      I'm working on a totally different actionscript file at

      /Users/username/Documents/Adobe Flash Builder 4/TestProject/src/TestProject.as

       

      in this file I try to import the DesiredClass:

      ---------------------------------------------------------------------

      package

      {

           import com.foreignproject.DesiredClass;

           import flash.display.Sprite;


           public class TestProject extends Sprite

           {

                public function TestProject()

                {

                var neatClass:DesiredClass = new DesiredClass();

                }

           }

      }

       

       

       

      ---------------------------------------------------------------------

      And then I try to add the class I want to the source path.
      I've tried adding each folder to the source path separately:

      /libraries/com/foreignproject/com/foreignproject/DesiredClass.as

      /libraries/com/foreignproject/com/foreignproject/DesiredClass.as

      /libraries/com/foreignproject/com/foreignproject/DesiredClass.as

      /libraries/com/foreignproject/com/foreignproject/DesiredClass.as

      /libraries/com/foreignproject/com/foreignproject/DesiredClass.as

       

      If I choose the libraries folder or either of the com folders then an error shows up in theTestProject.as file, saying:

      Definition com.foreignproject:DesiredClass could not be found.

       

      But f I choose either of the foreignproject folders then an error shows up in theDesiredClass.as file saying:

      a file found in a source-path must have the same package structure 'com.foreignproject', as the definition's package, ".

      What am I doing wrong? Please help. I bought a book on actionscript, started doing the flex-in-a-week series, read numerous online discussion boards, and I still can't import these classes.
      Thanks in advance.