10 Replies Latest reply on Jun 19, 2006 1:55 PM by Jim_W

    problem with #include

    actboy
      Hi

      Everytime that I use the #include "something.as"

      I always get the following error

      **Error** C:\work\flash\tryItOut_listenerObject_2.as: Line 1: Syntax error.
      ÐÏࡱá

      Can someone help me diagnose this error.
        • 1. Re: problem with #include
          blemmo Level 1
          Hi,

          #include is AS 1 syntax; if you're using AS 2, use 'import' instead:
          import something;

          greets,
          blemmo
          • 2. Re: problem with #include
            Level 7
            The #include statement is still extremely useful, even is using AS 2. I use
            it so that I can keep frame code in external files and use a more robust
            editor.

            The OPs error is somewhere in the included file, although it's pretty hard
            to tell exactly what it is.

            >**Error** C:\work\flash\tryItOut_listenerObject_2.as: Line 1: Syntax error.
            > ??????


            Since its on line 1, it could be the file encoding that's causing the
            problem.


            "blemmo" <webforumsuser@macromedia.com> wrote in message
            news:e668fa$pta$1@forums.macromedia.com...
            > Hi,
            >
            > #include is AS 1 syntax; if you're using AS 2, use 'import' instead:
            > import something;
            >
            > greets,
            > blemmo


            • 3. Re: problem with #include
              Level 7
              > #include is AS 1 syntax; if you're using AS 2, use 'import' instead:
              > import something;

              import and include are quite different in what they do
              --
              Jecykl


              • 4. Re: problem with #include
                blemmo Level 1
                Hi Jeckyl,

                could you explain the differences in short? I just learned from Raymond's response and a quick look at the help files that #include may also be used in AS 2. Now I'm wondering what's the difference between this and import?

                thx,
                blemmo
                • 5. Re: problem with #include
                  neil manuell
                  #include mearly includes code from an external source into the frame (eg you could write it in note pad and keep it as an external file)

                  import actually referances a class via its pakage, so that you onlu need to referance it by its class name, and not its package name
                  eg

                  import flash.filters.GlowFilter;
                  var filter:GlowFilter = new GlowFilter(0x000000, .8, 16, 16, 1, 3, false, false);

                  instead of

                  var filter:flash.filters.GlowFilter = new flash.filters.GlowFilter(0x000000, .8, 16, 16, 1, 3, false, false);
                  • 6. Re: problem with #include
                    Level 7
                    They do very different things.

                    #include lets you include anything at all anywhere at all. It effectively
                    just inserts the content of the .as file at that point in the script that is
                    being compiled, as if you'd typed it in yourself.

                    import is different .. it doesn't read in any files at all. Instead it is
                    very much like a 'with' statement. It saves you having to fully specify
                    where a class lives. eg These two do exactly the same thing:

                    1) without using import:

                    var myUser:macr.util.users.UserClass = new macr.util.users.UserClass();

                    2) using import to save typing:

                    import macr.util.users.UserClass;
                    var myUser:UserClass = new UserClass();

                    The actual reading of the .as file happens implicitly as a side-effect of
                    using a class. You don't need to use import to get a class .as file read in
                    .. only to save you some typing when you want to use it.
                    --
                    Jeckyl


                    • 7. Re: problem with #include
                      blemmo Level 1
                      Thanks fleece and Jeckyl! It really is quite a big difference... didn't know there's any difference 'til now.

                      • 8. Re: problem with #include
                        actboy Level 1
                        Hi,

                        How do I use the #include with AS2 is there a setting in Falsh 8 that I have to turn on?
                        • 9. problem with #include
                          neil manuell Level 1
                          no just go:
                          #include "myPath/myFile.as"

                          as Raymond stated earlier, it's probably for file encoding
                          make sure its UTF-8
                          • 10. Re: problem with #include
                            Jim_W Level 1
                            I've used #include before for referencing different style presets that I've created and sharedObject testing...however, I've simply copy/pasted the code and the files for use in a new project, and for some reason I keep getting a "can't find file" error.

                            Anyone experience this or have a clue as to why it's happening?

                            Thanks.