ActionScript 2.0 :: Moving Toward Mouse At Constant Speed?
Sep 17, 2006
i know you can make something move toward the mouse with
Code:
this._x+=(_root._xmouse-this._x)/speed
but when you get closer to the mouse it slows down, is there anyway to make it do this, but not slow down when it gets closer?
View 2 Replies
Similar Posts:
Sep 13, 2009
I cannot find how to have an object follow the mouse at a CONSTANT speed. The code I keep on finding is something like this:[code]I don't know if I'm just missing some really simple detail, or some major idea, but I'm pretty sure something as easy as this is possible.
View 1 Replies
Sep 13, 2009
I am using Flash 8 and AS2. I have been looking and looking, but I cannot find how to have an object follow the mouse at a Constant speed. The code I keep on finding is something like this:
Code:
onClipEvent (load) {
_x = 0;
_y = 0;
speed = 5;
} onClipEvent (enterFrame) {
endX = _root._xmouse;
endY = _root._ymouse;
_x += (endX-_x)/speed;
_y += (endY-_y)/speed;
}
The "/speed" part makes the object move slower the closer it gets.
View 3 Replies
Jan 2, 2010
I'm working on a Curling game and have a broom moving back and forth based on the mouseX position. Although I thought it would be as simple as recording the current broom position vs. the previous broom position that's not the case. This is because when you move back and forth the current and last postion may be at the very same point, like the center of the screen, depending on when exactly the mouse position is recorded. So, moving the mouse very slowly may give the same result and moving the mouse super fast where the x coordinate just happens to be recorded at or near the same point.
I tried using both an enterFrame event and a timer. Both yielded essentially the same results. I can't think of a way around this off the top of my head. Is there another way to record how fast the user is moving the mouse back and forth?
View 2 Replies
Apr 20, 2009
I am trying to get an object to track my mouse on press and i am using a tween. However, the nature of the tween is such that the time taken for the object would move would always be constant despite the distance.
I would like to make the object travel at a constant speed regardless of the distance. Is it correct for me to use a tween? If not what should I be using?The code for my tween is as follows.
map_mc.tracker_mc._x = map_mc._xmouse;map_mc.tracker_mc._y = map_mc._ymouse;startx = map_mc.crosshair_mc._x;endx = map_mc.tracker_mc._x;starty = map_mc.crosshair_mc._y;endy = map_mc.tracker_mc._y;
trackTweenx = new Tween(map_mc.crosshair_mc, "_x", Regular.easeIn, startx, endx, spd, true);trackTweeny = new Tween(map_mc.crosshair_mc, "_y", Regular.easeIn, starty, endy, spd, true);
map_mc.tracker_mc is the mouse cursor that would appear when onPress while the map_mc.crosshair_mc is the object that would track my cursor's movements.
View 1 Replies
Apr 18, 2010
I am trying to write a script to move a ball MC smoothly across the stage, without using tweens. I have thus far been successful, but there is one problem: the way I have it set up, speed increases with distance! I need the speed to remain constant. I understand why, but I can't figure out what approach to take to make the speed constant.
ActionScript Code:
var speed = 100;
var newx, newy, distx, disty, speedt;[code].....
View 2 Replies
Feb 14, 2012
I have Adobe Flash CS 5 and have been having difficulties trying to get a created tween to move at a constant speed. I have been converting a graphic I've created to a symbol and turning it into a motion tween, however I have only figured out how to move the tween on a frame by frame basis. Is there a way I can map out the full trajectory of the tween and then set it to travel along that pathway at a constant speed rather than moving from point to point within a certain number of frames? The desired result is a green circle that will bounce off the edges of the computer screen/window as it moves along at a constant speed in the appropriate direction. I am a flash novice and have been fiddling with the program for a few days
View 5 Replies
Jul 7, 2009
I want to have something on the screen move at a constant speed when a button is pressed. I'm not sure how to go about it. I have this for it to move 5 pixels at a time but I want it to move continually on holding the mouse down.
on (release) {
_root.bar.ball._x += 5;
}
View 1 Replies
Sep 22, 2004
I want to move a mc with constant speed until it reaches a certain x/y value then it slows down and stop. All in as of course.
View 3 Replies
Jan 24, 2012
I need to do an endless horizontal scroll of elements within a parent MovieClip.No matter what ever method I try, an element of 'drift' occurs and eventually the elements start to overlap.I've tried using relative recursive tweening for each element according but this method seems prone to quite a bit of error after repeated starts and stops.
//CODE START
function doScroll():void {
TweenLite.to(this, .25, {x:"20", ease:Linear.easeNone,onUpdate:checkPos,onComplete:doScroll});
}
//CODE END
I've reverted to doing absolute tweens to a predefined position using a contant speed. This seems to be more accurate but still some 'drift' occurs.
//CODE START
//_dest is predefined
var speed:Number = 500;
var dist:Number = this.x - _dest;
[code]....
View 2 Replies
Jan 27, 2009
I have to load some external data in a text box and scroll it vertically with a constant speed. And also give link to each sentence seperatly.what i have done is scroll text vertically,but it doesn't show all the text line as text file could have many lines even 100+.
myData = new LoadVars(); //load variable frm external txt file
myData.onLoad = function() {
myText_txt.html=true;
myText_txt.text = this.myVariable;
_root.onEnterFrame = function() {
[Code] .....
What I need is to particularly link each line. And should no limitation of text in .txt file.
View 0 Replies
Sep 20, 2009
How can i detect mouse speed with AS 3.0, and then put speed limit? Also can i use speed var for anything else? *sorry for my bad English, i live in non-english-speaking country*
View 9 Replies
Oct 28, 2009
and theres probably a simple solution but i dont know. I have an object travel at a constant speed across the stage area from left to right, How do i stop it at the Right side of the stage??
View 2 Replies
Mar 2, 2004
Basically what I am trying to accomplish is to make a rotating menu comprised of circles that are spinning at a slow constant speed, and when the mouse goes over a circle(button) the menu stops rotating.
View 2 Replies
Jan 4, 2007
I was wondering if there is a way to adapt this code I am using on a button.[code]This code works fine on the button and moves the movieclip each time the button is pressed by the viewer. My problem is, I would like the viewer to be able to just hold the button down and the movieclip would constantly apply the _y -=4.Is it possible to adapt this script to make it constantly move while the viewer holds down the button? As it stands now, it only moves once when the viewer clicks the button. So in order to move the movieclip 8 pixels, the viewer would have to click the button twice.
View 9 Replies
Jul 2, 2011
I need a movieclip to follow another movieclip at a constant speed.
View 5 Replies
Apr 22, 2007
I want to know how i can moving my scene by moving a mouse over them.
to understand what i want exactly ckeck this link :- [URL]
View 1 Replies
Mar 18, 2006
How can I change the speed of a moving car based on values input by user? Also, how can I make Flash calculate values of a function based on those input values?
View 1 Replies
Aug 24, 2009
[URL] when you have not clicked on all five dots, and you take the mouse of the stage, the interactive line should be deleted(graphics.clear(); ), and the little animation from the start should come back. my idea is to have a counter that ++ every frame, but when the mouse is moving on the stage the counter is constantly sett to 0. when the counter is, for example, 50 the animation i visible. do anyone have any methods that don't give the 50(for example) frame wait? and i would also like criticism and ideas on the rest.
View 7 Replies
Dec 4, 2008
why i am getting spurious mouse_out events when moving the mouse down or right but not up or left over a Sprite?
View 3 Replies
Dec 2, 2010
I must check how fast user rotates mouse wheel.
View 1 Replies
Aug 20, 2004
Some 360 degree animation is spinning on screen. Now: I would like to control the rotation with the XY of the mouse: e.g. I move the mouse to the left side, the animation is spinning leftwards. I move the mouse farther left, the anim. is spinning leftwards and faster. Naturally the same thing should work for the right side.
View 5 Replies
Dec 26, 2008
Can i trace the mouse speed ? Means can i check the mouse is moving faster or slower ? is there any command for that ?Or can i trace the mouse speed?
View 2 Replies
Jul 8, 2009
I am trying to do something quite simple but i am stuck. I have a huge object on screen and i want to do a mouse pan effect. But the panning speed will vary depending on the mouse distance from the center. e.g. the more left you get the mouse the faster it should move.
View 4 Replies
Jan 28, 2010
I am going to work on a game for my kids. Mot sure if it is a good idea for a game but it is an opportunity to learn more AS3. Anyway, Is there a way to run a function after the mouse has moved a certain speed for a certain amount of time? As if you were shaking somehting and then it explodes. Is there a way to even sense the speed of the mouse or would it be better to sense the number of times the mouse changes direction?
View 1 Replies
Aug 20, 2004
Some 360 degree animation is spinning on screen. Now:I would like to control the rotation with the XY of the mouse: e.g.I move the mouse to the left side, the animation is spinning leftwards.I move the mouse farther left, the anim. is spinning leftwards and faster. Naturally the same thing should work for the right side.
View 5 Replies
Jun 15, 2011
I want to make a counter get higher depending on mouse speed.
Code:
mousespeedy = _ymouse - oldymouse;
oldymouse = _ymouse;
posmousespeedy = Math.abs(mousespeedy / 100);
[Code].....
View 1 Replies
Sep 30, 2009
I have a circle wheel i want to rotate and the speed should be based on the mouse position. I also need to have easing in and out.
When the user hovers over the bottom of the circle it will begin to rotate one way and then th top of the circle would make it rotate the other way. The further to the top or bottom they are the quick it spins. It ideally needs to ease in and out when it starts and stops when the user moves the mouse away.
The circle will be the complete movie so 50% top and bottom each for each direction.
View 1 Replies
Apr 24, 2011
I've got a slideshow script that I've been using and I wanted to modify it a bit. I wanted to make it so that the further away from the center the mouse cursor is, the slower the slideshow. The closer to the center of the flash document, the faster it goes.Here's the code I've got thus far:
ActionScript Code:
// import tweener
import caurina.transitions.Tweener;
[code].....
View 0 Replies
Jun 26, 2005
How do you record mouse path and speed like [URL]
View 7 Replies