Detecting Mouse Coordinates, Tricky One
I have an MC that glows in and out, like a pulse. I want to have the pulse speed up as the mouse gets closer. I imagine it might take more than one mc with the pulse going at different speeds. Then when the mouse gets closer it will switch to a faster MC. I just don't know how to detect mouse coordinates and couldn't find any tutorials to help.
FlashKit > Flash Help > Flash ActionScript
Posted on: 01-10-2005, 11:17 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
REALLY Tricky - Detecting When Movie Clip Is Hits A
I've got a bunch of .swf's that are just an audio file, ending with a "stop()" command at the end.
I'm playing them in a host movie with this command:
loadMovieNum ("audio_02.swf", 20);
How can I detect when the audio file called hits the
"stop()" command?
I need this so I can go to the next frame, and unfortunalely, I cannot change the code in the audio .swf's.
Thanks in advance!!!
Mouse Goes To Coordinates
hi,
is it possible to make an animation where the mouse goes from one coordinate to another - automaticaly.
I need this for showing a certain point in the movie. I know it can be made with hide and show cursor, but I want that the mouse stays at the last coordinates and that one can continue from this new point.
thanks for help
caitanya
Help - Mouse Coordinates
I have a set of lines in my movie, and buttons that relate to them. When the mouse goes over the line, I want the button to move to whatever position the mouse is at.
Hope this is making sense...
I jsut need help in getting started... if anyone can help it would be appreciated.
Mouse Coordinates
I want to tell my movie to go somewhere if my mouse leaves certain Coordinates (for example a rectangle in the middle of the screen)
- I can't use mouseout or anything like that is has to be done with Coordinates
Thanks,
Kaan.
Mouse Coordinates
Anyone know how to grab the mouse coordinates and then display a movieClip exactly where those coordinates are when rolling over a button?
Also, is there a way where you could place the movieClip just a little off of those coordinates? say, maybe 50+/- pixels off of the y axis?
thanks.
4zero4
Mouse Coordinates
what would be the script that would allow me to get my mouse coordinates (xposition and y position) for Flash 5?
Mouse Coordinates
hello again. I posted last week and received a reply, but still can't make any headway on this problem.
I'm trying to make a script that recognizes if the mouse movement on the x-axis is higher or lower than it's last position. I know to use _xmouse for the position, but I can't grasp the logic on how to get it to compare two _xmouse positions in the same script without it giving the same coordinates for each. Does that make any sense? I guess it's something like this:
last mouse = ? _xmouse ?
current mouse = _xmouse
if current mouse > last mouse
goto...
else if current mouse < last mouse
goto...
Any help is appreciated. Thanks
-A
X And Y Mouse Coordinates
Just a quick Question....
I want to display the mouse x and y coordinates. I know how to do that, BUT is there any possible way to make it so there are no decimal places showing. I can only fit 3 characters max.
Thanks
Trev
How To Get Mouse Coordinates?
Hello everybody
I just got Flash CS3 and I need to work on a project that involves knowing where the mouse is when on screen. There will be an object that will follow the mouse as it is moved using tween. I found pretty much what I needed in a book but it is in AS2. I am trying to port it to AS3 without success. So being mthodical, I want to know, first of all how to access the mouse coordinates. When that is done, I will start working on the tweening. Here is the code I found:
Any help would be greatly appreciated.
Thanks
Rick
Attach Code
//Import the Tween and easing classes
import mx.transitions.Tween;
import mx.transitions.easing.*;
// Declare the hero instance on the Stage
var hero:MovieClip;
// Establish variables to store Tween instances,
// one for the X position of the hero and
// one for the Y position of the hero
var twX:Tween;
var twY:Tween;
// When the mouse cursor moves
onMouseMove = function():Void {
// Retrieve the current position of the mouse
var xPos:Number = this._xmouse;
var yPos:Number = this._ymouse;
// Establish the duration of a tween, in seconds
var duration:Number = 1;
// If a Tween instance has not been created yet
if(twX == undefined){
// Create a new Tween for the X position
twX = new Tween(
hero,
"_x",
Regular.easeOut,
hero._x, // Start value: current hero X position
xPos, // End value: current mouse X position
duration,
true
);
// Create a new Tween for the Y position
twY = new Tween(
hero,
"_y",
Regular.easeOut,
hero._y, // Start value: current hero Y position
yPos, // End value: current mouse Y position
duration,
true
);
// Whenever the X position Tween instance
// starts (or restarts), show the defense frame
twX.onMotionStarted = function():Void {
hero.gotoAndStop("defense");
};
// Whenever the X position Tween instance
// finishes its motion, show the offense frame
twX.onMotionFinished = function():Void {
hero.gotoAndStop("offense");
};
// If a Tween instance has already been initiated
} else {
// Change the end value of the X position Tween instance
// to the new X position of the mouse
twX.continueTo(xPos, duration);
// Change the end value of the Y position Tween instance
// to the new Y position of the mouse
twY.continueTo(yPos, duration);
// Retrieve the current absolute scale of the hero
var scale:Number = Math.abs(hero._xscale);
// If the end value of the X position Tween instance
// is to the right of the mouse, use a positive X scale value.
// Otherwise, if the end value is to the left of the mouse,
// invert the X scale value to flip the graphic horizontally
hero._xscale =(twX.finish > twX.position) ? scale : -scale;
}
};
Mouse Over Coordinates
I am looking to create a menu similar to the one found here:
http://www.denovoartwear.com/
All I need to know is how do you get the bar on this site the white rectangle) to go to a specific x-axis location on mouse over?
Any help would be much appreciated.
Mouse Coordinates
why doesn't this work
PHP Code:
onClipEvent (enterFrame) {
_root.xval.text = _root._xmouse;
_root.yval.text = _root._ymouse;
}
it's attatched to a blank mc on the main stage.
there are two dynamic text boxes that have var names of xval and yval ..... i thought this would work ... apparently i've missed something
thanks
Mouse X And Y Coordinates
I need to get the mouse x and y coords for a game I'm making. I know how to do it with fererence to another movie clip, button, textbox, ... but not to the stage. Any thoughts would be appreciated. If all else fails, I will attach a movie clip at (0,0) and then get the x and y coords from there, but if there is a simpler way, I would like to do that. Thanks in advance for your ideas.
Mouse Over Coordinates
I am looking to create a menu similar to the one found here:
http://www.denovoartwear.com/
All I need to know is how do you get the bar on this site the white rectangle) to go to a specific x-axis location on mouse over?
Any help would be much appreciated.
Mouse Coordinates All Over The Screen
How can I make flash capture the coordinates of the mouse outside of the movie?
I don't want to use a fullscreen flash movie.. Any other tricks anybody knows?
X Mouse Slider Within Certain Y Coordinates
Hey there!
I am doing a website for a photographer and I want to display thumbnails of his images on an x_mouse slider. However I only want the slider to work when it is within certain y coordinates.
My boy genius 18 year old co-worker figured out exactly the code I wanted inspired largely by one of lynda.com cd roms. Anyways the company just went under and I no longer have access to the code. DOH!
Here is a look at what I have so far:
onClipEvent ( enterFrame ) {
shift = ((320 - _root._xmouse)/20)
if (((this._x >= 277) && (shift > 0) && (_ymouse < 550)) ||
((this._x <= -287) && (shift <
0) && (_ymouse < 550))) {
shift = 0
}
this._x = this._x + shift;
}
Constraining Mouse Coordinates
Hi all,
I have a panorama that scrolls according to the mouse _x value (i'm getting the _x value from a dragged mc).
everything works great. the only problem is it scrolls when my mouse is not only over the panorma image but anywhere in the swf file. i want to constrict the scrolling to only the area that has the panororama image.
any suggestions would be helpful.
thanks!
mike
Play When Mouse Within Certain Coordinates?
I'm trying to play the main timeline as soon as the mouse moves over a certain area.
Let's say, something along these lines:
If mouse_X>300 and <600
and mouse_Y>600 and <750
play.
I'm guessing I need an empty movie clip that tracks the mouse and set's a
property or something. Please help.
Thank You,
- olaf
Mouse Cursor Coordinates
Hi
Can anyone help? I'm trying to show the position of the mouse cursor in a Flash 5 movie. Rather than having just 3 digits for both the x and y positions I would like a longer list of numerals, similar to how they are displayed in the status bar of vector drawing programs.
Thanks
Getting Mouse Coordinates When DragLock Is On
I'm making a game, and basically, at the bottom, I have a projectile launcher, and as you move your mouse from left to right, it shifts left to right but does not move up.
startDrag("_root.toss", true, 0, 382, 550, 382);
So it's locked to the 382nd y pixel, and can move between 0 and 550 on the x axis.
Now, depending on where you click, vertically, I want it to throw either a short, medium, or long toss. I have the tosses defined, all I need is to figure out a way to get the mouse's Y location so I can process it in this script:
on (release) {
if (_root.tosslocation<=140) {
// init toss length
tossdepth = 3;
// initiate throw
gotoAndPlay("long");
// line up splash
_root.splash3._x = throwx;
} else if (_root.tosslocation>140 && _root.tosslocation<215) {
tossdepth = 2;
gotoAndPlay("medium");
_root.splash2._x = throwx;
} else if (_root.tosslocation>=215) {
tossdepth = 1;
gotoAndPlay("short");
_root.splash1._x = throwx;
}
}
Get Mouse Coordinates From Scene
I have a buttons on my main scene when clicked takes you to the appropriate scene. What I want to do is retrieve the xy mouse coordinates from my main scene so I can place an mc in the next scene at the same spot it was clicked?
Track Mouse Coordinates
Ok, so I posted earlier about a "turkey chasing" game I'm doing in MX. In that game, I had the 'chasers' attached to the mouse in the basic "mouse-tracking game" style.
Now, I'm trying to rewrite this so that the "chasers" all work independently. There are 4 chasers. Each must come on screen one at a time (preferrably like 10 seconds apart from each other). The turkey is the mouse. I've hidden the mouse and replaced it with a movie clip of a turkey.
I'd like each of the "chasers" to come on screen (independently) and follow the mouse coordinates at random rates of speed so that the same 'chaser' doesn't catch the turkey every time. When one of the chasers does eventually "catch the turkey", I'll just go to a different point on the time line and load a screen that says "You Win" or "Happy Thanksgiving" or something.
Note: each chaser must be independent as they all will have different "faces". I can't just make one MC and just have that load that one 4 times at different intervals, unfortunately.
Can anyone help with this? I'm desperate for some assistance. What I originally wrote is apparently not what my boss had in mind and I've got a very quick turnaround on this.
Help!!
I'm attaching the *original* file that I worked with, where it was just following the mouse, but none of the chasers are independent of one another, nor do they stagger their intervals. It's straight "track the mouse". Using placeholder images (circles, squares) for the turkey and chasers for now.
Thank you in advance!!!
Controlling An MC According To Mouse Coordinates
I Would like to control an MC depending on where the position of the cursor is. When the cursor is over a specified area, the mc plays a certain keyframe. When it is not over this specified position it plays a different keyframe in the same MC.
Is this possible without using buttons? I don't want to see the cursor turn to a hand when my curser is over the designated area.
Can anyone help.
Thanks.
Daze
Go To Specifice Coordinates On Mouse Over
I am looking to create a menu similar to the one found here:
http://www.denovoartwear.com/
All I need to know is how do you get the bar on this site (the white rectangle) to go to a specific x-axis location on mouse over?
Any help would be much appreciated.
Change Mouse Coordinates
Hello
In flash I designed a button. I would like, on press, to change the mouse x and y coordinates, in other words to move it somwere else. Is there a script to do this?
thanks
Marcello
Tracking Mouse Coordinates For Map...
Hello all,
I did a search of the forums but I didn't come across anything that specifically answered my questions.
I have a map of Colorado and I want to dynamically display the _xmouse and _ymouse coordinates in dynamic text fields. The goal is to have the dynamic text fields to display the specific coordinates of the mouse wherever it may be on the map. These coordinates need to be dynamic so they can change with the movement of the mouse. I.E.- As you move your mouse you can visually see the dynamic text fields change their output.
I have gotten the coordinates to display properly but I am experiencing a couple of problems.
1) The dynamic text field is displaying the map's x/y coordinates but I would like for it to display latitude/longitude coordinates instead.
2) I am encountering some rounding issues with my current code. I would like for the dynamic text fields to display a total of 4 decimals. The code I am currently using only displays whole numbers.
-------------------------------------------------------------------------
Below is the current code I am using to display the dynamic mouse coordinates where Latitude and Longitude are the variable names for the dynamic text fields.
Code:
this.onEnterFrame=function(){
longitude="_longitude: "+Math.round(_ymouse)+"š N";
latitude="_latitude: "+Math.round(_xmouse)+"š W";
}
-------------------------------------------------------------------------
Below is a diagram of how I would like the coordinate system to be.
-------------------------------------------------------------------------
Questions:
1) Does anyone know how I can display my "desired" latitude/longitude coordinates instead of the actual x/y coordinates? Please keep in mind that as the mouse moves I want the dynamic text fields to update their displayed data with the appropriate coordinates.
2) How can I make the desired output display four decimals instead of zero decimals?
Thank you all in advance.
Scaling From X And Y Mouse Coordinates
I have a script that dynamically loads a series of movie clips onto a larger movie clip after reading a xml file. I have a blank movie clip called container_mc that is sitting on the stage in the upper left hand corner. Currently when the user clicks a lot that lot scales from the container_mc which is currently working, I want to determine where the mouse is on the stage and move the container_mc to that location then scale it. Here is my function:
function showBigLot(mClip:MovieClip) {
trace(this._x);
trace(this._y);
var lotNo:String;
var scalex:Number=7;
var scaley:Number=7;
mark = mClip._name.lastIndexOf("_");
lotNo = mClip._name.substring(4,mark);
trace(this);
var newClip:MovieClip;
trace(close_btn);
newClip = mClip._parent._parent.container_mc.attachMovie("lo t "+lotNo,"lot_"+lotNo+"_big_mc",mClip._parent.conta iner_mc.getNextHighestDepth());
close_btn._visible=true;
container_mc._visible=true;
mClip._parent._parent.gotoAndPlay(2);
close_btn.onRelease = function () {
close_btn._visible=false;
lots_mc._visible=true;
mClip._parent._parent.gotoAndPlay(6);
}
newClip.onRelease = function () {
newClip._visible=false;
lots_mc.close_btn._visible=false;
lots_mc._visible=true;
}
}
any help would be appriciated.
[CS3] Rotating Using Mouse Coordinates
Hi, i'm pretty new to flash action script.
I'm trying to create a simple site that when you move the mouse to the right of the screen a movie clip rotates one way abt 45 degrees and moves the other way when the mouse moves to the left.
any help would be great. I'm trying to get the effect of a horizon line rotating to the mouses movement around the screen.
cheers
One More Question, Mouse Coordinates
instead of using a rollOver button to close a menu, I would like to use something in actionscript like mousecoordinates. something like:
if(mouse_x > 200){
gotoAndStop(1);
}
This, ofcourse, doesn't work. The whole idea above in simple words:
if you move the mouse to x:240 and y:490 gotoAndStop frame 1.
Thanks!
Tipsko
Mc Moving According On Mouse X And Y Coordinates
Iīm trying to make a MC to change itīs x location according to the mouse position. Letīs say that the Mc moves to x=100 when the mouse_x is > 300 and y < 200. and moves back when the mouse goes back.
thanks
Display Mouse Coordinates
does someone know how to make a textfield that shows the mousecoordinates?
i hope someonecan help me
greetz Robb
Mouse Coordinates Over A Triangle
Hi Friends,
I need to make a tool where as you mouse over a triangle it displays the percentage of proximity to each of the triangle's three corners. Then, when clicked, it places a dot on that spot and the corresponding percentage values are sent to a web form. Please help! I am even willing to pay someone if you can help with this.
willstone06 @ gmail.com
One More Question, Mouse Coordinates
instead of using a rollOver button to close a menu, I would like to use something in actionscript like mousecoordinates. something like:
if(mouse_x > 200){
gotoAndStop(1);
}
This, ofcourse, doesn't work. The whole idea above in simple words:
if you move the mouse to x:240 and y:490 gotoAndStop frame 1.
Thanks!
Tipsko
Mc Moving According On Mouse X And Y Coordinates
Iīm trying to make a MC to change itīs x location according to the mouse position. Letīs say that the Mc moves to x=100 when the mouse_x is > 300 and y < 200. and moves back when the mouse goes back.
thanks
Display Mouse Coordinates
does someone know how to make a textfield that shows the mousecoordinates?
i hope someonecan help me
greetz Robb
Sending Mouse Coordinates To PHP?
I am attempting to create a Flash game that interacts with a MySQL database using PHP. I created a 600x600 pixel .jpeg in Fireworks, and would like to import it into Flash. I want the user to click on a spot of the image, and I want Flash to send the coordinates of the mouse click to a PHP file. Does anyone know how to do this?
I imported my jpeg as a button so that I could use the "onMouseEvent" function. I added getURL function to it for when the mouse is pressed, and put "handle.php?_xmouse". When I run the movie, I can click on the image, and it will call the PHP file. But it isn't passing the x mouse coordinate. It just passes the literal string "_xmouse".
Get Mouse Coordinates From A Scene
I have a buttons on my main scene when clicked takes you to the appropriate scene. What I want to do is retrieve the xy mouse coordinates from my main scene so I can place an mc in the next scene at the same spot it was clicked?
Papervision : 3d Mouse Coordinates?
I'm trying to bring a 3D object closer to the camera upon rollover. The problem is that when it moves, it can move itself right out from under the mouse cursor, thereby cancelling the rollover.
What I'd like to do is bring the object closer, but simultaneously tween it toward the mouse cursor in the X and Y dimensions, to fix this problem. However, as far as I can tell, I would need to calculate 3d scene coordinates for the mouse cursor. How might I go about this?
Thanks very much,
Displaying Mouse X/Y Coordinates Dynamically
I can't seem to find any of the sample movies that demonstrate this. I want to have text boxes that dynamically display the cursor's X and Y coordinates/positions in the clip. Any suggestions?
Umnbrella
Rotate Object Using Mouse Coordinates
Does anyone know how to or where I can find the actionscript for rotating an object on the spot by moving the cursor around the screen?.
Meaning when the mouse is to the right of the object it rotates left and if the cursor is to the left it rotates right.
while distance away from the object on screen affects the speed of rotation.
anyone know??
Yscale Of Mc Based On Mouse Coordinates?
What I have is a bolt of electricity to rotates around a fixed position to point towards the mouse, what I need to do is have it scale so that it always meets the end of the mouse pointer. How would I do this?
Text That Responds To Mouse Coordinates
Hi,
I saw a technique recently that involved text that went from dim to bright as you approached it with the cursor. Its very cool. I've tried creating it myself, but I havent been able figure it out. Any takers???
Cheers!
jenny
Rotation With Actionscript Using Mouse Coordinates
I'm working on a compass as navigation to a site that I'm working on, and the way it is set up is that the needle will rotates with the mouse as you roll onto the stage while a dial outside the compass rotates to the categories. Basically, what I want to happen is this: As you roll off the compass I want the needle to stop following the mouse and snap back up to whatever page you are in. I have included the fla file for anyone to take a gander at and hopefully give me a little help. Thanks in advance.
How To Use Mouse Coordinates To RollOut / RollOver?
Hey guys,
Would it be possible for me to find the mouse position of the cursor via the mouse coordinates in the flash movie, and then apply this to a rollOver or rollOut function? Can anyone explain how this works because at the moment im using invisible buttons to rollOut from a drop down menu but they just get in the way of other stuff and don't function perfectly. I also have a few other uses for it where invisible buttons aren't good for the situation.
Any help would be greatly appreciated!
Thx
Controlling MC On Behalf Of Mouse Coordinates
Hi
I want to be able to diaply different frames of a MC depending on the mouse position.
Ie. mouse position (100,100) => my_MC.gotoAndStop(5)
Ive got the following script:
function GetCoordinates() {
CoordinateX = _root._xmouse;
CoordinateY = _root._ymouse;
trace(CoordinateX);
trace(CoordinateY);
}
GetCoordinates();
However this only diplays the mouse position once - I cant get the function to (when the mouse is moved) diaplay the new coordinates?
Any help will be appreciated.
Thanks,
Mads
Mouse X/Y Coordinates: Javascript To Actionscript
Hello Everyone,
I am taking a value from javascript and want to use it in actionscript. I know how to pass the value (mouse X/Y coordinates) in to a dynamic text box but am stumped when it comes to reading that value when it changes and then using the new value in actionscript.
I would like to move an object’s (“ a car”) when the “X” value changes.
So I have Source files.
1.One is of a car that will move back and forth with the mouse, but only if the cursor is over the SWF.Example:
2.The second is html with JavaScript that will read in x/y and display it. Example
3.The third is an example my attempt of getting the X in to a dynamic text box. Now I can do that but how do I reference the value of that text box and use it again in the Actionscript. Example
Link for source files
Can someone please take a look and help me with this?
thank you,
Jason
BG Scrolling In Relation To Mouse Coordinates
Hi all!...
I'm making a site where I want the background image to pan/scroll in relation to the mouse placement. As in...if the mouse moves to the bottom left corner of the stage, the "camera" pans down to the bottom left corner of the BG image (thus technically the BG image pans to the up right). Additionally, I want the BG image to ease as it pans. I've been searching the forums for about 2 hours looking for something relating to this and I can't find a thing!
I know I need a mouse listener, but from there I don't know where to go...I really new to Actionscript, so I really appreciate your help!
Thanks so much!!!
An example of what I want can be found at:
http://www.karlaweb.tk/
by clicking on "entrar a disfrutar" and then clicking on "Experimental."
|