Well, two transparent sprite are too little. You should create some 20 or even more of them. Position the vertically all over the stage at equal distances and every time the user passes his mouse over one of them it starts a timer. When it passes over the next it checks the timer time. So you'll have the distance between the 2 sprites/movie clips (because you have to position them at equal distances over the stage) and the time needed to reach one from the other. From this you can easily calculate the speed. I tried to draw it. Hope you'll see it all right: You have the movie clips (the horizontal lines) created and positioned to stage with a loop. You set an onMouseOver function. Then it starts a timer(i don't know how to do it-i only just started with as3) when the mouse goes over one of those MCs. When it goes over the next you check the time it took to move from one to the other and you calculate the speed(If the stage is 600 i think a mc every 20 or 30 pixels should do it for the distance between the mcs-don't put too much of them or i would use too much cpu and i am not sure if it would be able to check the time with 31 fms-)speed = distance/time; And you 'v got the speed. you make a var speed:Number=0; and the in an enter_frame event you check the speed of the mouse between 2 mcs, multiply it with a fraction of 1 so the acceleration is not too big and
speed += speedBetweenMcs; ___________________________________________________ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ___________________________________________________ On Feb 13, 2008 8:04 AM, Paul Steven <[EMAIL PROTECTED]> wrote: > Thanks Cory > > Good point about the setInterval introducing redundant processing.Problem > with placing an invisible movie clip is, the users mouse may not pass over > this movie clip. For example, the movie is 600 pixels wide and 400 pixels > high. If I place a 400 high and say 10 pixels wide movie clip in the > center > of the movie, it is still possible for the player to move their mouse left > and right in the area to the left or the area to the right of the hidden > movie clip - hence no speed would be detected. I am therefore not sure how > to overcome this apart from insisting they move the mouse in a specified > area. > > Any ideas anyone? > > > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Cory > Petosky > Sent: 12 February 2008 21:52 > To: Flash Coders List > Cc: [EMAIL PROTECTED] > Subject: Re: [Flashcoders] Control speed by how fast mouse moving > > You'd be better off doing it in an onEnterFrame or a onMouseMove than > in a setInterval call -- code is only executed between frames anyway, > so your way just adds extra processing burden. > > Since all these events are only working once per frame, just comparing > x's isn't likely to give you meaningful data -- if a player moves his > mouse rapidly left to right at a rate that's some factor of your > framerate, you could easily get the same (or similar) x value at every > read. Increasing the framerate could help this, but brings other > problems. > > Consider placing a small, invisible movieclip on the path you intend > the user to move his mouse, and listen for onRollOver. You can use the > number of RollOver events per second to adjust speed. Just keep in > mind that you won't get any more events than your framerate. > > Finally, instead of adjusting speed directly, adjust max speed and > provide a constant acceleration toward the current max speed. For > example, if the user starts out at a rate that correlates to 50 mph, > his current speed should slowly increase at a constant rate over many > seconds until it reaches 50. Similarly, once the user begins to slow > down, the speed should decrease linearly to the maximum speed allowed > by the mouse move rate. This provides a slow acceleration at the > beginning -- which is probably what you want if you're emulating the > old button mashers -- and provides smooth speed changes as the game > progresses, which is definitely good. > > On 2/12/08, Paul Steven <[EMAIL PROTECTED]> wrote: > > I am trying to program a game where a character moves faster, the faster > the > > player moved the mouse left and right. A bit like the old Dailey > Decathlon > > Game where you had to hit 2 keys on the keyboard on after the other as > fast > > as you can to control the speed of say a character running. > > > > I could do with some advice on how to achieve this. > > > > I have a frame rate of 31 FPS, with a movie width of 600 pixels. > > > > Currently I am calling a function every 10ms to calculate the speed > > > > objShowerGame.updateSpeedInterval = setInterval(updateSpeed, 10); > > > > > > I compare the previous mouse X position with the current one and use > this > > difference as the speed. > > > > This isn't really working so I could do with some suggestions. > > > > Thanks > > > > Paul > > > > _______________________________________________ > > Flashcoders mailing list > > [email protected] > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > > > -- > Cory Petosky : Lead Developer : PUNY > 1618 Central Ave NE Suite 130 > Minneapolis, MN 55413 > Office: 612.216.3924 > Mobile: 240.422.9652 > Fax: 612.605.9216 > http://www.punyentertainment.com > _______________________________________________ > Flashcoders mailing list > [email protected] > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > _______________________________________________ > Flashcoders mailing list > [email protected] > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > -- Pedro D.K. _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

