dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Add counter depending on mouse speed?

  1. #1
    Member
    Join Date
    Oct 2006
    Posts
    48

    Add counter depending on mouse speed?

    Hello,

    I want to make a counter get higher depending on mouse speed.

    Code:
    mousespeedy = _ymouse - oldymouse;
    oldymouse = _ymouse;
    posmousespeedy = Math.abs(mousespeedy / 100);
    addMe += posmousespeedy;
    bar_mc._xscale = addMe;
    The addMe variable comes out as NaN. Help?

  2. #2
    Senior Member
    Join Date
    Jun 2003
    Location
    Kent, WA
    Posts
    536
    Makes sure you initialize your variables outside of your loop. If you don't, on the first pass through they will be undefined. When Flash adds something with undefined it equals NaN (not a number).

    Code:
    oldymouse = _ymouse;
    mousespeedy = 0;
    posmousespeedy = 0;
    addMe = 0;

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