1 Reply Latest reply on Oct 9, 2013 9:42 AM by sinious

    CreateJS MouseEvent



      I am trying to convert an AS3 file to HTML5. The createJS extension for flash seems like a great tool but I am experiencing some difficulties.

      My application cycles through an xml list of buttons, creates an object for each, collects the JS file that is the button (exported using Flash's createjs extension), positions it on the stage and then adds the appropriate event listener.

      The problem I am having is that, while the buttons do move to their correct positions visually, the event listener is remaining at the top left of the stage rather than where the button has been moved to. When I click at the top left corner of the stage then the alert fires but if I click where th button has been moved to then it does nothing.

      I have pasted some JavaScript code below.

      Any help would be very gratefully received.



      for(var i=0,ii=Modal.shellObjects.length; i<ii; i++){


      var f = Modal.shellObjects[i].id;

      var exportRoot = new lib[f]();



      if(Modal.shellObjects[i].x>-1){ Modal.shellObjects[i].image.x=Modal.shellObjects[i].x; }

      if(Modal.shellObjects[i].y>-1){ Modal.shellObjects[i].image.y=Modal.shellObjects[i].y; }


      case "closebtn":

      Modal.shellObjects[i].image.addEventListener("click", function(event) {

           alert("Close button clicked");






        • 1. Re: CreateJS MouseEvent
          sinious Most Valuable Participant

          Having never used the feature before but plenty of JS experience, I'm going to assume that the object was drawn into something (Canvas?) and the CreateJS library marked the area the object exists in as clickable via the handler and simply doesn't expect it to move. You can detect clicks on the canvas but cannot detect clicks on a graphical object drawn into a canvas itself, you do it by detecting position. If you investigate the addEventListener method of Modal it will probably show just that. That said, again, I haven't used CreateJS, I do it by hand. Unfortunately that doesn't definitively answer your question but if you open a new document, make a single button that moves completely on roll and export via CreateJS and it doesn't work, chances are it's a limitation of the current library.

          1 person found this helpful