Skip navigation
Currently Being Moderated

gotoAndPlay in Javascript?

Jan 31, 2014 1:09 PM

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:

http://blogs.adobe.com/flashpro/2013/12/18/actionscript-to-html5-flash pro-cc-2/

 

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?

 
Replies
  • kglad
    72,260 posts
    Jul 21, 2002
    Currently Being Moderated
    Feb 2, 2014 8:21 AM   in reply to jiggy1965

    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.

     
    |
    Mark as:
  • kglad
    72,260 posts
    Jul 21, 2002
    Currently Being Moderated
    Feb 2, 2014 3:25 PM   in reply to jiggy1965

    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 startes.  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)

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points