Skip navigation
jb3521
Currently Being Moderated

Add touch listener to item in Flash and Toolkit for CreateJS

Dec 19, 2012 11:05 AM

Tags: #ios #javascript #ipad #flash_cs6 #createjs #toolkit_for_createjs

I have an item on the Flash stage with an instance name "myCircle". I am trying to add a 'touchstart' listener to it, but it's not working when I export with Toolkit for CreateJS. I've tried the following in the Flash timeline:

 

/* js

this.myCircle.addEventListener('touchstart', function(e) {

e.preventDefault();

alert("touched");

          }, false);

*/

 

AND

 

/* js

myCircle.addEventListener('touchstart', function(e) {

e.preventDefault();

alert("touched");

  }, false);

*/

 

The following works, but the listener is on the whole page:

 

/* js

document.addEventListener('touchstart', function(e) {

e.preventDefault();

alert("touched");

  }, false);

*/

 

Also tried getting the id of the touched item in the document listener -alert(e.target.id), and it always returns 'canvas' no matter what I touch. Any suggestions appreciated.

 
Replies
  • kglad
    72,357 posts
    Jul 21, 2002
    Currently Being Moderated
    Dec 20, 2012 6:29 AM   in reply to jb3521

    use:

     

     

    /* js

    this.myCircle.onClick=function(e) {

    alert("touched");

              };

    */

     

     
    |
    Mark as:
  • kglad
    72,357 posts
    Jul 21, 2002
    Currently Being Moderated
    Dec 20, 2012 12:04 PM   in reply to jb3521

    you're welcome.

     
    |
    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