4 Replies Latest reply on Oct 17, 2006 8:23 AM by Newsgroup_User

    JSON and Actionscript

    Crandom Level 1
      I am trying to implement JSON into Flash Actionscript. I have found the script that allows this from http://json.org/ (found here: script (.as)) in the form of a Actionscipt Class.

      I tried to include this class with:

      #include "JSON.as"

      but it returns this error on running:

      **Error** JSON.as: Line 34: Classes may only be defined in external ActionScript 2.0 class scripts.
      class JSON {

      Total ActionScript Errors: 1 Reported Errors: 1


      I thought that it is an external class and i am merely using #include to be able to use it.

      Am i doing something wrong? Or is ther some other way to activate a class?
        • 1. Re: JSON and Actionscript
          coldMiner Level 1
          place the .as file in a sub folder, example:
          #include "as/JSON.as"
          • 2. Re: JSON and Actionscript
            Level 7

            "coldMiner" <webforumsuser@macromedia.com> wrote in message
            news:eh0v6m$7hb$1@forums.macromedia.com...
            > place the .as file in a sub folder, example:
            > #include "as/JSON.as"

            This is a Class so you will want to import the class, not #include the code
            since Classes must be defined in external .as files.

            so you want...
            import JSON;
            if JSON.as is in the same directory as your fla.

            If your JSON.as is in a directory called as that is in the same directory as
            your fla then you need to change two things...
            1. change to
            import as.JSON;
            2. change line 34 of JSON.as to
            class as.JSON {

            HTH


            • 3. Re: JSON and Actionscript
              Crandom Level 1
              Thanks for replying! I tried both meathods, but unforunately coldminers did not work, it just came up with the same error, however Newsgroup User's did work, so thank you!
              • 4. Re: JSON and Actionscript
                Level 7

                "Crandom" <webforumsuser@macromedia.com> wrote in message
                news:eh22qr$h1b$1@forums.macromedia.com...
                > Thanks for replying! I tried both meathods, but unforunately coldminers
                > did not work, it just came up with the same error, however Newsgroup
                > User's did work, so thank you!

                Welcome.