Skip to main content
Participating Frequently
April 20, 2024
Answered

doesn't work on a mobile screen

  • April 20, 2024
  • 2 replies
  • 329 views

Hello, does anyone know how to make the touch screen react to pressing an object? ? )) Here is the function for the mouse and desktop on primer (in Adobe Animated) - this.ball.on("pressmove", moveBall ); . But it doesn't work on a mobile screen. Is there an alternative? Just not a click, but a constant click on an object is read

    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    There isn't any specifically for mobile, as far as I can tell.

     

    But the official documentation for CreateJS is at createjs.com.

    2 replies

    JoãoCésar17023019
    Community Expert
    Community Expert
    April 20, 2024

    Hi.

     

    Please make sure you're enabling touch interactions by calling...

    createjs.Touch.enable(stage);


    ... in the beginning of your code.

    Regards,
    JC

    Participating Frequently
    April 20, 2024

    Thank you. Please tell me, is there a link to the documentation that describes all the commands when working with canvas on a touch screen?

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    April 20, 2024

    There isn't any specifically for mobile, as far as I can tell.

     

    But the official documentation for CreateJS is at createjs.com.

    kglad
    Community Expert
    Community Expert
    April 20, 2024

    i don't see a problem.

    Participating Frequently
    April 20, 2024

    I'm sorry. Attached  -  fla and example code. 

    I repeat. Everything works fine on a desktop with mouse controls, but does not work on a mobile device with a touch screen. Can you tell me what to do?

     

    var root = this;
    this.yes.visible=false;
    this.ball.on("pressmove", moveBall );
    
    function moveBall(e) {
    		var p = stage.globalToLocal(e.stageX, e.stageY)
    		e.currentTarget.x= p.x;
    		e.currentTarget.y= p.y;
    	
    }
    
    this.ball.on("pressup", dropBall);
    
    var myN=0;
    
    function dropBall () {
    	
    	if(root.ball.x>85 && root.ball.x < 1180 && root.ball.y > 65 && root.ball.y < 365 ) {
    		root.ball.alpha=0.5;
    		root.ball.x=root.myRect.x;
    		root.ball.y=root.myRect.y;
    		root.yes.visible=true;
    		myN++
    		if(myN>5) {
    			root.ball.visible=false;
    		}
    	} else {
    		root.ball.alpha=1;
    		root.yes.visible=false;
    	}
    		
    	
    }