Jump to content

please help - starting out easelJS/adobe Animate/HTML5 Canvas is like reading sand


subtlefly
 Share

Recommended Posts

Hi team,

So I have a tutorial (paid) but I am trying to understand something that I don't know what is going on.. I am (trying to be) running the interaction from a game.js file where all the code will be stored.  I think I have worked out how to set up a web server and run the project as an index file (otherwise the interactions being read from the game.js file do not work)- this seems like a PITA but I have it working now.

So I have started a new project.  I have a movie clip that has two frames in it (off and on) and the switch moves depending on if the light is off or on.  Then I have a button instance name gobutt that can be used to call the lightAndSwitch movie clip to be on or off - 

here is the code

1746809441_Screenshot2022-12-28at3_35_11pm.thumb.png.20153b3776f029da1a95e16691e5d7b2.png

class Game{
    constructor(exportRoot, stage){
        this.root = exportRoot;
        this.stage = stage;
        this.init();
    }
    
    init(){
        const game = this;
        this.root.gobutt.on('click', function(){
               game.root.lightAndSwitch.gotoAndPlay("on");
            
        });
    }
}

So its all connected - no errors being thrown, but it doesn't work!

This is the same pathway as the example given (That works) but I am changing something by making my own project.  How do I address the button and the movie clip from the game.js file?

Thanks for your help

sub

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...