Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Is It Possible To Set Initial Mouse Position?



I have a flash that responds to my mouse's position/movement. However, I also need the mouse to be at the center of the movie when it starts. Is it possible to set the initial mouse position in the flash movie?



FlashKit > Flash Help > Flash ActionScript
Posted on: 09-29-2005, 11:06 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Set Initial Mouse Position
i guess it must be possible with actionscript to set the initial position of the mouse when loading a new page...for example to the far left of the screen....but how???sorry to ask such noob questions all the time :roll:

_xmouse - Difference In Current And Initial Mouse Position
Hi guys,

This problem is now driving me completely mad now and I just can't seem to solve this...

I'm trying to make a thumbnail slider that will move a movieclip to the right when you move the mouse left, and move the movieclip left when you move the mouse right. I DON'T want any inertia effects or anything like that; the clip just needs to move the same number of pixels that you have moved the mouse.

To get this to work I need to know the DIFFERENCE between where the mouse was to where it is now. To get the currentX mouse position I am simply using -


Code:
currentX = _xmouse;
The main trouble is calculating the initialX value of the mouse, which needs to be its X position that it was just before it became its _xmouse position. I don't know how to calculate this?

I have done this using setInterval to calculate the currentX value at a different rate to the initialX value but it gives choppy results..... any help out there?

Initial Position Of Movieclip
I've got a question that I think is pretty basic, but I just can't figure it out despite searching lots of forums.

I've got a movieclip on the stage and I'd like to set its initial X and Y position to some variables before I start moving it around. I don't want to hardcode its initial position. In as2, I'd do something like


Code:
onClipEvent(load){
this.initX = this._x;
this.initY = this._y;
}
Obviously this doesn't work. Instead I could put the following code in when I go to move the object:


Code:
if(this.initX == undefined){
this.initX = this._x;
this.initY = this._y;
}
but this seems like such a hack (maybe the old AS2 way was too!). Anyway, I'm hoping someone can enlighten me on the "right" was to go about this.

thanks.

Storing Initial Position Of MC
Okay maybe its because I've been working on this all day and can't think straight any longer but this seems like it should be really obvious and I'm getting frustrated that I can't think of how to do it.

I have a movie clip sitting just off stage. When the file is first launched I want to record the x position of this movie clip in a variables, say startX. When a button is pressed (and there are several of these) I am using Voetsoejba's easing code (brilliant) twice, once to move an MC just in the x direction (easeX):
(on the main timeline, whre movetxt and content are the two MCs)

ActionScript Code:
//record initial positionsmenux = movetxt._x;menuy = movetxt._y;_global.startX = getProperty(_root.content, _x);_global.startY = getProperty(_root.content, _y);MovieClip.prototype.easeX = function(to) {    this.onEnterFrame = function() {        this._x = to-(to-this._x)/1.3;        if (this._x>to-1 && this._x<to+1) {            delete this.onEnterFrame;      }    };};

and another to move another mc in both x and y directions (ease):

ActionScript Code:
//also on main timelineMovieClip.prototype.ease = function(x, y) {    this.onEnterFrame = function() {        this._x = x-(x-this._x)/1.3;        this._y = y-(y-this._y)/1.3;        if (this._x>x-1 && this._x<x+1 && this._y>y-1 && this._y<y+1) {            delete this.onEnterFrame;            this._x = x;            this._y = y;        }    };};

on the button

ActionScript Code:
on (release) {    //bunch of other stuff    _root.content.easeX(135.6);    _root.content.gotoAndPlay(2);    _root.content.holder.loadMovie("calendar.swf");    movetxt.ease(menux, menuy);}

There is also, on the content box that eases in, a close button with this script to ease it back off the stage:

ActionScript Code:
on(release){    _root.content.easeX(_global.startX);    _root.movetxt._visible = false;    _root.movetxt._x = menux;    _root.movetxt._y = menuy;}


So here is what is happenning: first time you hit the button to load it works like a charm but when you hit the close button it eases mostly, but not all the way, off the screen. Hit a button again to bring back the content mc and it disappears completely. Hit it a third time and the content mc just appears in place where it should, it doesn't ease.

So what is going on? What am I doing wrong? Is all this blather too complicated to sort out without an fla?

thanks for any help!

Storing Initial Position Of MC
Okay maybe its because I've been working on this all day and can't think straight any longer but this seems like it should be really obvious and I'm getting frustrated that I can't think of how to do it.

I have a movie clip sitting just off stage. When the file is first launched I want to record the x position of this movie clip in a variables, say startX. When a button is pressed (and there are several of these) I am using Voetsoejba's easing code (brilliant) twice, once to move an MC just in the x direction (easeX):
(on the main timeline, whre movetxt and content are the two MCs)

ActionScript Code:
//record initial positionsmenux = movetxt._x;menuy = movetxt._y;_global.startX = getProperty(_root.content, _x);_global.startY = getProperty(_root.content, _y);MovieClip.prototype.easeX = function(to) {    this.onEnterFrame = function() {        this._x = to-(to-this._x)/1.3;        if (this._x>to-1 && this._x<to+1) {            delete this.onEnterFrame;      }    };};

and another to move another mc in both x and y directions (ease):

ActionScript Code:
//also on main timelineMovieClip.prototype.ease = function(x, y) {    this.onEnterFrame = function() {        this._x = x-(x-this._x)/1.3;        this._y = y-(y-this._y)/1.3;        if (this._x>x-1 && this._x<x+1 && this._y>y-1 && this._y<y+1) {            delete this.onEnterFrame;            this._x = x;            this._y = y;        }    };};

on the button

ActionScript Code:
on (release) {    //bunch of other stuff    _root.content.easeX(135.6);    _root.content.gotoAndPlay(2);    _root.content.holder.loadMovie("calendar.swf");    movetxt.ease(menux, menuy);}

There is also, on the content box that eases in, a close button with this script to ease it back off the stage:

ActionScript Code:
on(release){    _root.content.easeX(_global.startX);    _root.movetxt._visible = false;    _root.movetxt._x = menux;    _root.movetxt._y = menuy;}


So here is what is happenning: first time you hit the button to load it works like a charm but when you hit the close button it eases mostly, but not all the way, off the screen. Hit a button again to bring back the content mc and it disappears completely. Hit it a third time and the content mc just appears in place where it should, it doesn't ease.

So what is going on? What am I doing wrong? Is all this blather too complicated to sort out without an fla?

thanks for any help!

Changing Orbiting Movieclips Initial Position.
So I need to have multiple objects rotating around a point in an elliptical orbit. I've got the code to do this just fine, but naturally I want them to start at different points along that orbit.

onClipEvent(load)
{
cx = Stage.width/2;
cy = Stage.height/2;

rad = 84; // radius of circle

speed = 30;
speedScale = (0.001*2*Math.PI)/speed;
}

onClipEvent(enterFrame)
{
var angle = getTimer()*-(speedScale);
this._x = cx - 1.5*(Math.sin(angle)*rad);
this._y = cy - Math.cos(angle)*rad;
}

That's the code I've got so far, attached to the objects in orbit.

Setting Initial Position After Loading Pngs Into Mc's
It's the last few lines of actionscript I'm having issues with. The movies stay were they are initially loaded and are not moved to x:20, y:20 using the array. Can anyone assist?



ActionScript Code:
_root.Total_Parts = 4;
var mcl:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
mcl.addListener(listener);
listener.onLoadInit = function(mc:MovieClip) {
    mc.origSize = {w:mc._width, h:mc._height};
    mc._x = Toolbox._x+((Toolbox._width/2)-(mc.scaledSize.w/2));
    mc._y = Toolbox._y+((Toolbox._height/2)-(mc.scaledSize.h/2));
    mc.centered = {horiz:mc._x, vert:mc._y};
};
var Part:Array = new Array();
for (var i:Number = 1; i<=_root.Total_Parts; i++) {
    var Part_clip:MovieClip = createEmptyMovieClip("PNG_Loaded_"+i, i);
    mcl.loadClip("PNG/Part_"+i+".png", Part_clip);
    Part[i] = Part_clip;
    Part[i]._x = 20;
    Part[i]._y = 20;
}
Part[1]._x = Part[1].centered.horiz;
Part[1]._y = Part[1].centered.vert;

My Buttons Doesn't Come Back On Initial Position
hello,
i've a little problem with my buttons wich are movieclips
if you rol over and out to fast they stay "on" (they do not come back to initial position)
i've used actions: rolover >goto and play frame 2
there is a stop on frame 1 and 5
rolout > goto and play frame 6 (so it plays to frame 9 and come back and stop on frame 1 :initial position)

u can see them on my site : http://www.ontheground.be


thanks

My Buttons Doesn't Come Back On Initial Position
hello,
i've a little problem with my buttons wich are movieclips
if you rol over and out to fast they stay "on" (they do not come back to initial position)
i've used actions: rolover >goto and play frame 2
there is a stop on frame 1 and 5
rolout > goto and play frame 6 (so it plays to frame 9 and come back and stop on frame 1 :initial position)

u can see them on my site : http://www.ontheground.be


thanks

Mouse X Position To Control Movie Position?
Hi, my understanding of actionscript is very basic and I'd like some help with writing a very simple script. Basically the x position of the mouse should control the play position of a movie. Do I need something like an event handler (I'm not sure exactly what these do, but I've seen similar scripts that seem to use them).

Mouse. Hide, Mouse.show-on New Position
On button release i hide mouse because mc start to play
and on the end of that mc i show mouse agin.

Plese tell me how to move mouse in new position on screen with mouse.show() function

tenx,
m.

Position Of Mouse = Position Of MC
How would I tell a movie clip to move along with the mouse without dragging. Also how would I define the area to which the movie clip can move?

Mouse Position ?
Here is my problem ..... i want 2 lines to follow my mouse ... like a X and Y line, but am not sure how to do this . i would like somthing like this
http://www.yigal-azrouel.com/

If anybody could please help me it would be greatly apreacted . If posible could i get some code??? to use as an example .
thanks.

Mouse Position?
Where I dit it wrong?
I want to get dynamicly y position of mouse in text box.

on the first frame I typed:

" var y = 0; "


and on movie action I typed:

"
onClipEvent (mouseMove) {

y = _root._ymouse;

updateAfterEvent();
} "

Thank you in advance

Mouse Position
How can i read the current mouse position on the x and y axis and output this to the screen?

Thanks

Position Of Mouse
is there a function that gives the position of the mouse? I've tried it with a drag movieclip and then reading the x and y coordinates .. .it works but there can only be one movieclip that can be dragged at a time .. so i tried a while (thrue) construction but it didnt work to so any suggestion?

Mouse Position
Hello,

I am trying to detect on the main timeline when the mouse is within a box or certain coordinates. Then once it is within these coordinates the movie will go to frame 2. Then once it is outside these coordinates then it will go back to frame 1. Is this possible.

If it helps an example of the coordinates of the box are

Top Left x=75 , y=23
Bottom Left x=75 , y=70
Bottom Right x=150 , y=70
Top Right x=150 , y=23

I hope this makes since.


This is what I put on the first frame of the main timeline. Nothing happened at all.

if (_ymouse >= 23 && _ymouse <=70 && _xmouse >=75 && _xmouse <=150) {
gotoAndPlay ("Scene 1", 2);
}

Thanks for any help!

Mouse Position. How?
Hi all,

Hope someone can help with this one.

Im trying to get the mouse cursor to change it's position on the screen when a button is clicked.

So when u click the button, the mouse jumps to the top corner of the screen.

any ideas?

Mouse Position
Is it posible to position the mouse curser at the beginning of a movie?

example:
I want that my mouse is at
_xmouse = 100
_ymosue = 200
as soon as my movie starts...

any ideas?

with:
_xmouse and _ymouse i can only recieve coordinates but not send!

Getting X Mouse Position
what is the command for getting the mouse position???
i got this:

scrollspeed = getProperty("../scrollmenu", _x);

i want the scrollspeed of a menu to be equal to the x position of the mouse... how do i do this???

so when i come to the center of the menu that it stops scrolling and the further you move your mouse the faster it scrolls?

ive seen it in some of you little name banners.. but how do i do it?

thanks..

Mouse Position
How can I know if the mouse is on the clip or not ?

Possible To Set The Mouse's Position?
Hi I am using flash mx is it possible to set the mouse's position without the user moving it?

thanks

Is It Possible To Set The Mouse Position?
Can you set the position of the users mouse without him moving it??
thanks

Mouse Position
I NEED MORE HELP!!

I have an image of logos 3000x100 long in an 650x400 swf which I control to go left and right according to were the mouse is using the following code;

xcenter = 325;
xdiff = _root._xmouse-xcenter;
_root.content._x = _root.content._x-xdiff/8;

The problem I have is that I would like to stop the image going off the stage when it reaches either end !, I realise that I would probarly need to use the IF statement, but cannot get my head round it.

CAN SOMEONE HELP?

Mouse Position
Hi,

Question: I have made a movieclip with two states, labeled "a" and "b".
Now onClipEvent I drag that movieclip, becoming my cursor.. that part is easy but what I want the mc to do is change states when it's in some part of the movie
For the dragging:
onClipEvent (enterFrame) {
this._x = _parent._xmouse;
this._y = _parent._ymouse;
}
but when the cursor mc comes in to a specified area of the stage I want it to go to Label "b"
Can anyone help?
Furthermore; is there a way to check if the mouse is outside of the movie (when inside a frameset) so it doesn't show the custom cursor mc?

Mouse Position
Greetings,

How do I set my movie so that whilst my mouse is not in it, it believes my mouse to be in a certain position? To be specific, I have a mouse over drag menu, but before I even mouse over it, it moves. It is initially moving. I want it initially stopped and the user to gain control once placing the mouse over the movie. Thank you kindly for your help.

Herk

Mouse Position
Hi all, I have a question to mouse position. I know about _xmouse and _ymouse properties, but I have another problem.

Is there any way to determine if the mouse is above the scene? I tried to use _xmouse and _ymouse properties but when you move the mouse very quickly off the scene, those properties return bad values.

Sorry for my english.

I know the reason of this behavior, the flash movie is simply slower than the mouse move (if the mouse move is quick enough ). I know it depends on framerate, but if you have some actionscripts on your objects, the movie can be so slow you can move the mouse off the scene faster than movie can realize with no problem.

So, can somebody advice please?

PS.: Gonna look for some info about detecting mouse-object collisions, that coud be a solution, so if you know smt about it, please, write it down. Thanks a lot.

Mouse Position
looking for ways to subtley guide the user around my page, wondered if there is any script that can tell the mouse to jump to a location on a certain frame, to indicate to the user where they are to click

cheers

Mouse Position.
im wondering if i can get the moused X position(left to right) and turn it into a percent(MousePositionX / Scene width)... then mutiply it by the number of frames in a movie clip(% * movieclipframes) then round it to the neared one so i have a whole number, and have the movie clip goto, and stop on that frame number.... so the further right i move my mouse, the further into the movie clip it goes, having the very left be the very begining of the movie, and the very right be the end.

Mouse Position
I need a movie clip to go on a specific frame when the mouse is roling out of the swf. Anyone can give me a quick tip for this?

Thanks!

Mouse Position
Heres the situation:

I would like when a user clicks on the button to set a different mouse coordinates, to move the mouse cursor...?


any help would be appreciated?

[F8] Help With Mouse Position
Hey everyone,

I've just started messing around with this and Im looking for some input about how to achieve a certain effect in dealing with mouse positioning.

So I've figured out how to make a movie clip move in relation to where the mouse is using this simple code below which just gets placed directly on the movie clip I want to affect.


Code:
onClipEvent(mouseMove) {
this._x = 500 + (_xmouse - 0)*+0.05;
this._y = 500 + (_ymouse - 0)*+0.05;
}


But I want to make it so that the movie clip moves slowly into position like it does on this site: Fort Minor

Any ideas?

Thanks.

[F8] Mouse Position
Sorry for being a fool but I can't figure out why this wouldn't work... ?

if (_xmouse>600 && _xmouse<800 && _ymouse>20 && _ymouse<180) {
dial.gotoAndPlay(2);
} else {
dial.gotoAndPlay(12);
}

cheers!!

The Position Of The Mouse
hiiii, how r u ?

how can I locate the fix position of the mouse when the movie loaded??

ex: when start the movei the first position of the mouse x=20 & y =60

please help me

The Position Of The Mouse
hiiii, how r u ?

how can I locate the fix position of the mouse when the movie loaded??

ex: when start the movei the first position of the mouse x=20 & y =60

please help me

Mouse Position
Hi,

I want to be able to continuously display (refreshing) the x,y positions of the mouse in a textfield. could anyone give me an answer quickly?

thanks in advance!!!

Set Mouse Position
Hello,

How i can set the mouse position to determinated value of "x" and "y" ?

i like set the pointer mouse position (yes, the "arrow" that we see on screen) to determinated value of "x" and "y" conditionated by an event...

thanks!





























Edited: 01/09/2008 at 05:42:45 PM by jose_luis

Mouse Position
hi,
how can i use mouse position in as3?any codes?

Mouse X Y Position Help Please
Ok I have been randomly entering numbers so that when you move the mouse left the images move right and so on...

This is the code I’m using [I think I got it from FK originally a while back??].


PHP Code:



onClipEvent (mouseMove) {
    xmousepos1 = _xmouse;
    ymousepos1 = _ymouse;
    if (xmousepos1>xmousepos2 && ymousepos1>-98 && ymousepos1<-33) {
        _root.scrollclip.nextFrame();
    }
    if (xmousepos1-98 && ymousepos1<-33) {
        _root.scrollclip.prevFrame();
    }
    if (ymousepos1<-98 || ymousepos1>-33) {
        play ();
    }
    xmousepos2 = _xmouse;
    ymousepos2 = _ymouse;






As you can see from my FLA it’s not quite working the way it should. Is there a cleaner way of doing this?
If so could someone kindly point me in the right direction before I beat myself to death with my mouse.

FLA Download

Thanx in advance.

_y Mouse Position
I have a menu bar that I want to enter and exit the stage when the _y mouse position goes below a certain point. What code would I use for this?

I am confused.

Mouse Position
Hi all does anyone know how I can find out if my movie goes off of my swf?

W i K


Set The Mouse Position
does anyone know how to control the mouse position?

i want to move the mouse to a specific position on the screen. how can i do that?

thanks!!

Mouse Position
Here's the problem!
I have a movieclip which i want it to rotate according to the mouse position. Wut do i have to do???

Mouse Position
Never touching flash before I have decided upon implementing a navigation which involves playing a movie forward and backwards across the screen.

Using two buttons I have been able to get the movie to move across the screen from the left to the right and vice versa upon rollover.

I would like to somehow eliminate these buttons and make this work depending upon the horizontal location of the cursor.

Looking at the scripts I’m sure this can be done but I’m having trouble figuring out how to tell it to play the movie clip one direction when I am on the left side of the screen and to play the movie clip the opposite direction when the cursor is on the right side of the screen.

Well, I don’t know if my description makes any sense but any help is greatly appreciated.

Moving An Mc According To Mouse Position....
but with a kind of elastic feel to it. like on http://www.centeroftheworld.com

how do i do this?

Force Mouse To X Position?
Is it possible to move the mouse pointer to a set x position with code?

Jump To Mouse Position
i am experimenting with backgrounds for my site. i want to make a movie clip that will jump to where ever the mouse is when the user clicks the mouse, here is what i have just now but i won't work, can anyone shed some light on this.


on (release) {
follow._x = _root._xmouse;
follow._y = _root._ymouse;
}


also if anyone could tell me how to make the animation smooth as if it had been tweened, it would be excellent

thanks in advance

- jgo

Help. Scrolling By Mouse Position
How do I allow a user to scroll through a list, or, for example, a horizontal row of pictures, simply by repositioning the mouse left or right (from the center)?

Thanks in advance.

Scrolling By Mouse Position
Let's say I have a horizontal image that I want the user to be able to scroll through based on the mouse position.

For example, if the mouse is on the left part of the menu, the mene will scroll left (and vice versa). Many sites have menus like this, including the Macromedia site, so I presume it's fairly basic.

Can anyone tell me how to do this, or at least point me in the right direction? I gather it has something to do with the mouse x/y position on the screen.

Thanks in advance.

Copyright © 2005-08 www.BigResource.com, All rights reserved