Calculating the height of an object to percentages in relation to the mouse position


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // Calculating the mouse position within an object to percentages in relation to its height
  2.  
  3. // var scale = 100 ( result range from 0 - 100 )
  4. // var scale = 10 ( result range from 0 - 10 )
  5. // var scale = 1 ( result range from 0 - 1 )
  6.  
  7. trace( ( mySprite.mouseY / mySprite.height) * scale );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.