Skip to main content
asafl48373404
Participant
February 22, 2017
Answered

flip symbol

  • February 22, 2017
  • 1 reply
  • 3176 views

hey

how can i flip symbol in animate?

i want to flip the player in game when you press the left key.

the result need to be player player walk right and when i press left he turned to left.

help please?

    This topic has been closed for replies.
    Correct answer just.emma

    how the syntax and the function will look if i in function of the parameter keycode?


    root = this;

    document.onkeydown = function(e) {

        switch (e.keyCode) {

            case 37: flipLeft();

                break;

            case 39: flipRight();

                break;

        }

    };

    function flipLeft(){

      createjs.Tween.get(root.mcName).to(

      {scaleX:-1},

      250, createjs.Ease.elasticOut);

    }

    function flipRight(){

      createjs.Tween.get(root.mcName).to(

      {scaleX:1},

      250, createjs.Ease.elasticOut);

    }

    Please note that mcName should be changed to match the instance name of the movie clip that you want to flip.

    Also, just wanted to mention that Stack Overflow was super helpful in figuring this out: keyboard events - Detecting arrow key presses in JavaScript - Stack Overflow

    1 reply

    just.emma
    Inspiring
    February 22, 2017

    To flip a symbol:

    Select your symbol.  Go to Modify > Transform > Flip Horizontal.

    asafl48373404
    Participant
    February 22, 2017

    but i want that it happen automaticlly

    like in super mario

    when you press right he walk right,when you press left the same mario walk left with the face to left.

    //right arrow

      if (e.keyCode==39){

      kid.alpha=1;

      /*kid2.alpha=0;*/

      backR.x -=10;

      kid.x +=10;

      }

    this is for right walk, i want that when i press left  the mario turn left so i need that the flip will be in the code

    Legend
    February 22, 2017

    You just set the X scale negative instead of positive.