10 Replies Latest reply on Mar 23, 2017 5:05 PM by Colin Holgate

    two mutually exclusive locations of code

    dariuszk32546812 Level 1

      Adobe Animate can hold the code in two locations:

      1 Window - Actions

      2 Properties - Publish - Class (.as text file)

       

      When anything is added into second location (#2), code from first one (#1) stops working (can't find class etc.).

       

      How to

      a fix that and how to

      b convert code (#1) into (#2) to move everything to .as file and hold entire code in one place as a whole ? (most important question)

      c how to export code #1 to text file not manual mouse using copy-paste in each window

       

      #b seems to be possible because when the swf file is opened in the Sothink SWF decompiler, entire code looks like taken from #2:

      Package package_name

      {

          import flash.display.*;

          ...

          dynamic public classmainTimeline extends MovieClip

      {

          public var ....

      etc.

      So Adobe Animate when converts fla into swf, perhaps also converts the code from #1 to #2.

        • 1. Re: two mutually exclusive locations of code
          kglad Adobe Community Professional & MVP

          When anything is added into second location (#2), code from first one (#1) stops working (can't find class etc.).

           

          that's an incorrect generalization.  some timeline code is problematic when combined with class code but, in general, timeline code and class code can coexist.

           

          and there's no simple conversion from timeline code to class file code.  eg, a stop() on frame 22 of a movieclip added to the main timeline's frame 10 requires looping (eg, enterframe) to encode in a class file.

           

          otoh, everything other than play(), stop() and goto's is pretty easily converted from timeline code to class code.

          • 2. Re: two mutually exclusive locations of code
            dariuszk32546812 Level 1

            Even automatic addition of this default empty container:

             

            package  {

              

                import flash.display.MovieClip;

              

                public class foto extends MovieClip {

                  

                    public function foto() {

                        // constructor code

                    }

                }

              

            }

             

            causes:

            Scene 1, Layer 'Actions', Frame 2, Line 43, Column 40    1046: Type was not found or was not a compile-time constant: MouseEvent.

            Scene 1, Layer 'Actions', Frame 2, Line 78, Column 40    1046: Type was not found or was not a compile-time constant: MouseEvent.

            Scene 1, Layer 'Actions', Frame 2, Line 117, Column 40    1046: Type was not found or was not a compile-time constant: MouseEvent.

            Scene 1, Layer 'Actions', Frame 2, Line 152, Column 40    1046: Type was not found or was not a compile-time constant: MouseEvent.

            Scene 1, Layer 'Actions', Frame 3, Line 11, Column 40    1046: Type was not found or was not a compile-time constant: MouseEvent.

             

            So any sample code from the internet (#2) corrupts #1 and an entire movie file.

             

            This "package" lacks apparently something. Sothink SWF decompiles creates a lot of code in #2 from #1.

            • 3. Re: two mutually exclusive locations of code
              kglad Adobe Community Professional & MVP

              i assumed you understood the basics of class files and were asking a question with a different level of expertise.  so, ignore my message 1.

               

              to use class files, you must explicitly import all needed classes.  eg, those error message indicate you need to import the mouseevent class:

               

              import flash.events.MouseEvent;

               

              i'm pretty sure, after you do that, you'll find there are more classes that need to be imported.

              • 4. Re: two mutually exclusive locations of code
                dariuszk32546812 Level 1

                Thank you. This worked, but my Trial version ends in few hours so I rather won't do anything what I wanted (getting swf variable by HTML file javascript).

                • 6. Re: two mutually exclusive locations of code
                  dariuszk32546812 Level 1

                  Adobe Animate should automatically add

                  import flash.events.MouseEvent;

                  line and other lines to #2 needed by timeline code (#1). Because so far attempt to add code to #2 (.as file) corrupts an entire movie.

                  Or rather the timeline code should work inependently (without or with #2).

                  • 7. Re: two mutually exclusive locations of code
                    kglad Adobe Community Professional & MVP

                    what line of code is causing the error and what's the error?

                    • 8. Re: two mutually exclusive locations of code
                      dariuszk32546812 Level 1

                      Errors are listed in the second post of this thread (1046: Type was not found ...) and cause too. This is very severe disadvantage of code editors in Animate. And lack of possibility to save code #1 into txt file.

                      • 9. Re: two mutually exclusive locations of code
                        kglad Adobe Community Professional & MVP

                        this?

                        Scene 1, Layer 'Actions', Frame 2, Line 43, Column 40    1046: Type was not found or was not a compile-time constant: MouseEvent.

                        Scene 1, Layer 'Actions', Frame 2, Line 78, Column 40    1046: Type was not found or was not a compile-time constant: MouseEvent.

                        Scene 1, Layer 'Actions', Frame 2, Line 117, Column 40    1046: Type was not found or was not a compile-time constant: MouseEvent.

                        Scene 1, Layer 'Actions', Frame 2, Line 152, Column 40    1046: Type was not found or was not a compile-time constant: MouseEvent.

                        Scene 1, Layer 'Actions', Frame 3, Line 11, Column 40    1046: Type was not found or was not a compile-time constant: MouseEvent.

                        • 10. Re: two mutually exclusive locations of code
                          Colin Holgate MVP & Adobe Community Professional

                          You wouldn't add the import lines to the AS file if they are not needed by the AS file. You would add the import line to the timeline code, because that's where they are needed. From the look of it, both frame 2 and 3 would need this as the first line (maybe any line, but usually import lines are at the top):

                           

                          import.flash.events.MouseEvent;