1 Reply Latest reply on Sep 6, 2006 5:37 AM by Newsgroup_User

    #include "Base64.as"

    Goo101
      I have a .as file which contains the code for a class called Base64. When I try to pull it into my code using the '#include' method, is it generating the following error!?

      **Error** C:\Documents and Settings\Administrator\My Documents\Touch Screen Project\Touch Screen Slides v7\Base64.as: Line 24: Classes may only be defined in external ActionScript 2.0 class scripts.

      If I can't use the '#include' method, how do I go about referencing the functions contained within the class?
        • 1. Re: #include "Base64.as"
          Level 7
          Goo101 wrote:
          > I have a .as file which contains the code for a class called Base64. When I try
          > to pull it into my code using the '#include' method, is it generating the
          > following error!?
          >
          > **Error** C:\Documents and Settings\Administrator\My Documents\Touch Screen
          > Project\Touch Screen Slides v7\Base64.as: Line 24: Classes may only be defined
          > in external ActionScript 2.0 class scripts.
          >
          > If I can't use the '#include' method, how do I go about referencing the
          > functions contained within the class?
          >

          To import a class you use 'import' and to include pieces of ActionScript
          you use '#include' saved in an .as file.

          You can only put one class per .as file and it has to be the same name
          as the class. With includes, the file can contain all random statements
          but no classes.

          Your class saved as Base64.as
          ------------------------------
          class Base64 {
          public function Base64 () {
          }
          public function foo () {
          return "I'm foo";
          }
          public static function bar () {
          return 7;
          }
          }

          In your FLA
          --------------
          import Base64; // import the class
          var oBase64 = new Base64(); // create an object using the class
          trace( oBase64.foo() ); // call the object's methods
          trace( Base64.bar() ); // or call a class' static function

          James O'Reilly
          www.jamesor.com