6 Replies Latest reply on Dec 23, 2015 6:50 AM by Colin Holgate

    Toolkit for Create JS - Need simple code snippet for button onClick

    PixelGirl

      I am just now learning about the Toolkit for Create JS in Flash Professional and am trying to teach myself how to use the JS part.

       

      It would be great if there were a set of js code snippets, similar to the action script code snippets for us designers to use.

       

       

      I have a character on the stage whose mouth is a movie clip with 4 different expressions. The timeline for the mouth mc has each mouth expression on its own layer with a label for the keyframes.

       

      So the hierarchy is Stage > globeman > mouth.

       

      I also put 4 buttons on the stage which I want to play the individual mouth expressions on the character. The buttons have their layer names and their instance names the same: "big_smile", "small_smile", "open", "closed".

       

      It seems there must be a simple way to control the child movie clips within Flash using onClick events but I'm not sure where to put the code in the timeline.

      I know that with ActionScript you are not able to attach scripts to buttons.

       

      So in the generated html file, within the <script> tag I put the following but it doesn't work:

       

      btn_big_smile.onClick = function(){

           stage.globeman.mouth.gotoAndPlay("big_smile")

      }

       

      etc.. for each one.

       

      Tried putting it in the exported .js file as well.

       

      What am I doing wrong here?