A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Multiplying mouseX value: possible?

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    19

    Question Multiplying mouseX value: possible?

    Hello again,

    I would like a bit of help with something I have been working on. I have this mc that responds to mouseX , only the mc is very short in frames, it's only 25 frames long. This way the mouseX is only the first 25 pixels of my stage, so it only responds to that. Is there any way I can multiply this value to, let's say, 20 times?

    Thank you in advance.

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You just need to scale the relationship.
    Code:
    var value:int = Math.floor(25*mouseX/stage.stageWidth);
    The mouseX/stage.stageWidth gets you the mouse position as a percentage of the stage width. Then multiply that by 25 which is the number you want at 100%. Then take the floor of that so that you get an int rather than a Number. You could use round there.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center