3 Replies Latest reply on Sep 9, 2008 8:10 AM by MixMastaJames

    seperate AS file for flex project

    MixMastaJames Level 1
      I've just started using Flex, and although I love it, I hate having to scroll up all the time to edit the AS3 code in the <mx:Script> tags.. so i was wondering if there was a way to save out all the AS3 code to a seperate as file and tell the mxml file to use the code in that file.

      Thanks.
        • 1. seperate AS file for flex project
          EvolvedDSM
          Sure is! Rather than explain, I'll let Adobe do the talking.
          http://livedocs.adobe.com/flex/3/html/help.html?content=usingas_4.html

          "To make your MXML code more readable, you can reference ActionScript files in your <mx:Script> tags, rather than insert large blocks of script. You can either include or import ActionScript files."

          Hope this helps!

          EDIT:
          TL;DR version:
          add all your <script> code minus the SCRIPT and CDATA tags to an actionscript file. Then in your application, you'll need to include your new actionscript file using <script source="path_to_script.as"/>

          And that's it. I just tested on a small app of mine and works perfectly.
          • 2. Re: seperate AS file for flex project
            Level 7

            "New to AS3" <webforumsuser@macromedia.com> wrote in message
            news:ga5pgp$rb8$1@forums.macromedia.com...
            > I've just started using Flex, and although I love it, I hate having to
            > scroll
            > up all the time to edit the AS3 code in the <mx:Script> tags.. so i was
            > wondering if there was a way to save out all the AS3 code to a seperate as
            > file
            > and tell the mxml file to use the code in that file.

            You can include it.

            Or, right click next to the first line of the script block (where the line
            numbers are) and select Add Bookmark..

            Then Window>Other Views...>General>Bookmarks

            HTH;

            Amy


            • 3. Re: seperate AS file for flex project
              MixMastaJames Level 1
              Thanks for the replies.. I knew about the stinking include, just haven't used it since AS2 (write classes most of the time, but didn't want to do it with this). So DUH to me :)

              I did use bookmarks, but i really wanted to seperate out the different set of functions I had for each part of it into their own files.. which the include allowed me to do.

              Thanks again :)