6 Replies Latest reply on Feb 13, 2015 6:46 AM by kglad

    gotoAndPlay in Javascript?

    jiggy1965 Level 1

      I've been looking into turning my flash banners and buttons into html5 equivalents. Using the CreateJS option. Which turns my animations into javascript, I already experimented with (first time I'm doing this). Now for the interactivity like mouse clicks on my buttons or in banners. I've read that I then have to translate my actionscript code into javascript equivalents. I know a lot of languages, but haven't really worked with javascript much. As a tutorial I looked at this page:



      It says I should change this actionscript code:


      var self = this;this.btnJump.onClick = function() {self.gotoAndPlay(“endWait”);}


      Into this javascript code:

      var self = this;this.stop();this.btnJump.addEventListener(‘click’, onClickJump);function onClickJump() {self.gotoAndPlay(“endWait”);


      I glanced through my javascript books to brush up on my knowledge and I kind of can make sense of this. But things like 'gotoAndPlay', that's still actionscript and not javascript, right? That's the reason I can't find gotoAndPlay and gotoAndStop for example in my javascript books? Perhaps it has been recreated in CreateJS as a javascript function? So not really basic javascript, but a created javascript function called the same and working the same, but coded in basis javascript syntax so that it does the same thing? It that how it works?


      Next to any javascript books to brush up on my knowledge (know any good ones), where can I find documentation on CreateJS so I can read and learn how to translate my actionscript into its javascript equivalents? Something like the actionscript language reference pages in Flash, but then in CreateJS/Javascript style?

        • 1. Re: gotoAndPlay in Javascript?
          kglad Adobe Community Professional & MVP

          those are both actionscript snippets.  the first is as2 which createJS can't handle.  the second is as3 which createJS can handle.


          your second snippet would work with flash cc html5 publishing IF you used quotes and double quotes that flash recognizes.

          1 person found this helpful
          • 2. Re: gotoAndPlay in Javascript?
            jiggy1965 Level 1

            don't think so? If you look at the article:



            It clearly says that the used actionscript is commented after export to html5 and to be replaced with the javascript variants.


            It seems more likely to me that the createJS javascript library is using javascript functions named after the actionscript commands which make the html5 file do the same thing like originally programmed in actionscript. I know it's not typically javascript, things like gotoAndPlay. But I'm guessing that they have copied the actionscript functionally of typical actionscript commands into functions written in javascript code. Functions which, in javascript, do the same thing in html5 like the actionscript does in flash.


            So - I think - it's not that createJS reads actionscript (both as2 and as3 are commented after export), but that it makes the exported html5 read the typical actionscript commands as javascript. So, I you know what I mean, the html5 file sees the javascript command, or rather the recreated createJS javascript function 'gotoAndPlay' and executes that createJS javascript function. The function which, programmed in typical javascript syntax, makes the object do the same thing in html canvas or whatever as it's actionscript/flash counterpart.


            Am I correct in thinking this way?

            • 3. Re: gotoAndPlay in Javascript?
              kglad Adobe Community Professional & MVP

              there have been a series of revisions and refinements to createJS since it was first introduced.  when the author wrote that blog, things probably worked whatever way he states.  currently, the code you posted works perfectly well.


              here's your code in a fla:  http://www.kglad.com/Files/forums/test9.fla


              when i publish the html  page, i see no problem:  http://www.kglad.com/Files/forums/test9.html   // (click the rectangle and you should be taken to a frame with an oval)

              1 person found this helpful
              • 4. Re: gotoAndPlay in Javascript?
                www.123bee.com Level 1

                Hi i am using flash professional CC and i have generated one flash html5 canvas output and i want to check that output in ios devices,

                so how can i check it? should i generate ipa? pls help me i am stuck here

                • 5. Re: gotoAndPlay in Javascript?
                  Pat481 Level 1


                  • 6. Re: gotoAndPlay in Javascript?
                    kglad Adobe Community Professional & MVP

                    you're welcome.