syntaxactionscript

Cant figure out purpose of hyphen in actionscript


I am new to coding in actionscript3. My question is what the hyphen do in this code?

tween = new Tween(menuScreen,"y",Strong.easeOut,menuScreen.y, -  /* <---- */
    menuScreen.height / 2,0.8,true);//Creates a tween animating the MenuView up 

Solution

  • It is the unary - operator.

    When used for negating, the operator reverses the sign of a numerical expression.

    That is, the code provided is equivalent to the more common form:

    tween = new Tween(menuScreen,"y",Strong.easeOut,menuScreen.y,
      -menuScreen.height / 2,0.8,true)
    

    The placement of the newline is unfortunate (for readability), but does not affect the parsing.