4 Replies Latest reply on Feb 21, 2008 8:00 AM by ooba

    Question about import statements

    ooba Level 1
      Why is it that I must have the import statement on the
      same frame
      and same layer
      as the AS code that utilizes the Class that I am importing?

      At least that is how it appears.
        • 1. Re: Question about import statements
          i_am_captivate Level 1
          I don't know what's up with that either, I have to put the code to import the file(s) on the same frame as where I used them. I use the Tween class frequently and it's kind of an annoyance to have to put them on the same frame all the time.

          I thought maybe it would be possible to create a global function and call them that way but that didn't work either...

          ¿ Confused ¿
          • 2. Re: Question about import statements
            Rothrock Level 5
            Because that is how it works.

            Remember, import doesn't actually "import" anything. It is just a shortcut so you don't have to type the whole package name every time you use the coded in your example.

            It is actually kind of nice when you come back to code later or if you open somebody else's code (that you have to update or change) and to see at the top, "Oh, this bit of code has a reliance on class blah.blah.Yadda." In a way it kind of helps enforce a bit of good coding practice.
            • 3. Re: Question about import statements
              Rothrock Level 5
              imjustabeginner - there are probably a lot of ways to avoid this. One of the easiest, but probably not the best. Is to make a layer above (or below) your actionscript layer and call it functions. Then make a reusable function so that you can just send that function your instances and some params and it will handle applying the Tween class for you.
              • 4. Re: Question about import statements
                ooba Level 1
                That works. I was trying to break it apart into 3 layers.
                1. Imports
                2. Functions
                3. All other conditional business logic

                But by ensuring that you only have the use of the class in the function you can combine 1 and 2 above and 3 can be used to make the calls to the functions.