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




Mouse Detection



Is it possible to detect if the mouse pointer is not sitting somewhere on your flash movie(say somewhere else on the browser) and then have a specified movie unload?

Does this make sense?



FlashKit > Flash Help > Flash Newbies
Posted on: 01-31-2002, 03:56 PM


View Complete Forum Thread with Replies

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

Mouse Angle Detection II - Getting A Root Mouse Value
Hey,

I have been looking at and developing the following tutorial:

http://www.actionscripts.org/tutoria...II/index.shtml

Whilst changing it I was looking to place this tutorial in it's own movie, which could then be placed on to, say the root.

By doing this AS was not picking up the value of the mouse, because (I am guessing) of the following code:
x = this._xmouse;
y = this._ymouse*-1;

The mouse was no long on "this" but in a movie which was above it.

I thought that this could be solved be changing this. to either _root. or _parent. but neither of them worked.

I have had a search on these forums and net, and haven't come to a solution yet, so I was wondering if anybody could advise me on what code I could use to get the value of the mouse on a root or parent movie.

Thanks

Mouse Detection
I am trying to create a scrolling menu which when the user moves the mouse away from the menu area the menu scrolls at a set speeed.

What is the best method to set a variable when the mouse is over the menu area.

i have tried several if statements such as

if (_root._ymouse>50){
flag = 1;
}

but this doesn't seem to work


?????
Thanks

Mouse Detection?
Is it possible to know which Mc(non-regular shape) does mouse over with? Does the mc return the name on mouse over or i have detection which mc is the mouse touching?

Mouse Detection? Please Help
Hello all,
Can anyone help with this? I have a panoramic image slider embedded in a main movie. The slider works fine, but I would like for the slider to work only when the mouse is on it. Now the slider moves no matter where the mouse is within the flash movie, and that is quite annoying. How can I make the slider function only when the mouse is on top of it? I am really stuck, and any help would be greatly appreciated. Here is the url for the examplehttp://www.toddstudiosinc.com/test/ .

much thanks!

Mouse Detection
The basics
Im using Flash Mx, and Im very new to Actionscript and Flash

The Objective
I have this animation of seperate icons moving on a circle guide, so when the user goes around the circle with the mouse i want the icons to move on that circle guide as the mouse moves in a circle.

My attempts
Ive got pretty damn close with an If loop and the _xmouse but still not there!

It would be appreciated if someone could give me some light on this matter for I only have so much hair I can pull! lol

Thank you in advance!

[F8] Mouse Off Of Mc Detection
This is a recurrent problem.

The case is that I have a stage with 700 x 700 pixels and a centered mc with 620 x 620 pixels on it. I must to detect when mouse goes off of the mc, but it's not news that when you move mouse too fast, Flash cannot capture the action as faster, and it keep registering _xmouse and _ymouse as if it was still there within mc.

Any idea?

Mouse Detection Breaking Down
I am using a flash menu in one frame on an htm page that controls the pages in another frame. I want to close the menu on a rollout. Using the rollout state of a button or using xmouse and ymouse, if the user moves entirely out of the htm frame too quickly the rollout does not register. Is there some way for Flash to check to see if the mouse has left the swf entirely?

Anybody have an idea?

Thanks,
Brad

Detection The Scrollbutton On The Mouse
Does anyone know how i can detect the scrollbutton (on your mouse) in flash?

I'm gonna use it for a txt scroller so it has to be something like.

on (keyPress "<Mousescrollbutton.up>") {
DO THIS
}

on (keyPress "<Mousescrollbutton.down>") {
DO THIS
}

Anyone who can help me out?

Greetings Uhmmie

Mouse Detection ---> Keyframe
I've got a big problem:

I want a movie clip to move along the time line as the mouse mooves a scroller.

Said in another manner: like a text scroller, but instead of changing the _y position of the movie clip, it would send it to the desired frame in real time.

Can anybody help me with this ?

Mouse Detection Help Needed
Hello,
I recently completed this tutorial:
http://www.programmingart.com/free/t...ashvolume.html
My question is related to the up and down volume arrow buttons, and to mouse clicks in general. Is there any way to detect if the mouse is CURRENTLY down? I can use buttons to make the volume go up or down, but I can't seem to figure out how I could allow the user to press and hold the button, and make the volume increment higher or lower consecutively as long as the mouse button remains depressed. Basically, I need to detect if the mouse is down at any given moment, exactly like the Key.isDown function built into flash.
I would greatly appreciate any help and methods around this, and thanks a lot!
Jeremy
Programming Art

Right Mouse Click Detection...
Can Flash 5 ActionScript detect a right mouse click?

Right Mouse Click Detection...
Can Flash 5 ActionScript detect a right mouse click?

Mouse Inactivity Detection
hi everybody!!
I need "something" that makes my projector reset to the first frame of the timeline, in case nobody is at the desk for a couple of minutes...how would be the script for such a control?? should it be attached to a mc or how??
thanks!

Mouse Idle Detection?
Are there any scripts to detect if the mouse is idle? thanks. I'm trying to make a MC disappear with onMouseMove and i want the MC to re-awaken as the mouse is idle.. anyone know how? thanks

Mouse And Rotation Detection
i need some help i can't figure out what i'm doing wrong here. i followed this very easy and clear tutorial . i understand the concept but i cant seem to apply it on flash
this is what i come up with

thanks in advance

[F8] Mouse Inactivity Detection
Hi,

Just wondering if anyone can help me with creating a function that is called if the mouse is not moved for a set period of time (ie. 1 minute) and then cleared once the mouse is moved again.
Kind of like a screensaver.....
I already have the code I want to be called after a minute of inactivity, I just dont know how to write the function to call and clear it.

This is what I need to call after the mouse is idle for 1min.
code:

display = function(){
delay = 2000;
forwardInterval = setInterval(flip_mc, "flipForward", 3000); flip_mc.onLastPage = function(){
clearInterval(forwardInterval);
lastPageInterval = setInterval(closeLastPage, delay);
};

function closeLastPage() {
flip_mc.flipGotoPage(0);
clearInterval(lastPageInterval);
forwardInterval = setInterval(flip_mc, "flipForward", 2000);
};
};


Can anyone help me out ?

Collision Detection - Following The Mouse
Ok, basically, i have a fish following the mouse, which works fine, but then i want the fish to be restricted to it's 'bowl', with the black lines being boundaries.

Currently, it works like so: click me

The .fla file should be attached if that would help.

The movie is basically made up of the fish movie clip which has the following code applied to it:


Code:
onClipEvent (enterFrame) {
myRadians = Math.atan2(_root._ymouse-this._y, _root._xmouse-this._x);
myDegrees = Math.round((myRadians*180/Math.PI));
_root.yChange = Math.round(_root._ymouse-this._y);
_root.xChange = Math.round(_root._xmouse-this._x);
_root.yMove = Math.round(_root.yChange/20);
_root.xMove = Math.round(_root.xChange/20);
this._y += _root.yMove;
this._x += _root.xMove;
this._rotation = myDegrees += -180;
}


this makes the fish follow the mouse

Then within the movie clip, frame one has the script:

Code:
a = eye._y-_ymouse;
b = eye._x-_xmouse;
angleA = Math.atan2(a, b);
degrees = angleA/(Math.pi/180);
setProperty("eye", _rotation, degrees);
a2 = eye2._y-_ymouse;
b2 = eye2._x-_xmouse;
angleA2 = Math.atan2(a2, b2);
degrees2 = angleA2/(Math.pi/180);
setProperty("eye2", _rotation, degrees2);


which makes the eyes follow the mouse also

frame two is just a gotoandplay thing to make sure the eyes are constantly refreshed


so yea, i'm fairly new to flash, and i just want the fish movie clip to be restricted within the bowl movieclip (the black lines and theres also a 0% alpha line at the top, so it's essentially keeping a box within a box, but all the tutorials i've found seem to be when you're manually controlling an object, which doesn't apply.

any help would be fandabbydosey

Problem With Mouse Detection
Hallo to everybody!
This is my first thread and I hope I didn't brake any rule.

So, my problem is like this:
I have a stage with a little area on the left side where my cursor change with my custom one(bluebox1). In that area I can move the mouse only on the x axis(from left to right and right to left).
After a while(5 seconds) my cusom cursor(blueox1) is free and I want it to move to the very right side of the stage and stop.
My problem is that this move of the bluebox1 is intended to be from the last position of the cursor - from there to go to the left side of the stage.
I attached the fla for more details because, I'm sure, my English is poor and I didn't explained nice.

I put this AS on the first frame of my stage:

Code:
bluebox1.onEnterFrame = function(){
Mouse.hide();
bluebox1.startDrag(this,false,100,100,100,0);
bluebox1._y = 100;
}
bluebox1.onRollOut = function(){
bluebox1.stopDrag();
Mouse.show();
}

My AS is Basic

[CS3] Left Right Mouse Detection
again in as2, how can you write code to say if the cursor is east of a movie clip change movie clip and if it is west of the movie clipchange the movie clip, if you understand, here is kinda what i want but u have to drag the movie clip...
http://www.flashkit.com/movies/Basic...1805/index.php
thanks
funky

Mouse Inactivity Detection
hello..
i want make a screensaver for my flash
i get a coding :


var inactiveTime = 5000;
// 5 seconds
function tooLong() {
trace ('you took long');
}
var intrvl = setInterval(tooLong, inactiveTime);
onMouseMove = function () {
clearInterval(intrvl);
intrvl = setInterval(tooLong, inactiveTime);
};
onKeyDown = function () {
clearInterval(intrvl);
intrvl = setInterval(tooLong, inactiveTime);
};
Key.addListener(this);


i've changed the trace ('you took long') with loadmovie('flash.swf','page'), but it doesn't work.
anyone can help me???

Mouse-Angle-Detection-I In AS3?
I'm looking for something similar to
http://www.actionscript.org/resource...-II/Page1.html

But in ActionScript 3.0 I somewhat understand the math, but I'm not sure if any of the math functions have changed, or how to implement it.

Thanks!

Mouse Inactivity Detection
MOUSE AND KEY INACTIVITY DETECTION

I wondering if anyone can something about mouse and key inactivity settings and how to make a script for it.

It is meant to be a trial work there i have a pet or such a thing that moves and jumps as long as you are active with your mouse or key pressing.

if not that script will take you to the beggining because the pet is run away.


But it would not be anything commercial or like that but a trial ENTERTAINING pet for my homesite. YOU TAKE CARE OF IT BY mouse click and move, and even keypress (i thougt to make soundclips to each and every of letters but it is not difficult)

So can anyone this, or have ready script or maybe can give me some leading clues about it. Is it possible to make in flash. because i tried to find some mouse inactivity script of some kind but there are no such.



Erik

Idle Mouse Detection?
Here's a question - Say I have a flash projector running at full screen and the user clicks a button which opens up a browser leading to a site. Is there anyway for Flash to detect when the user is idle and that when it happens, it goes back to the flash movie? Thanks for your time.

Idle Mouse Detection?
Here's a question - Say I have a flash projector running at full screen and the user clicks a button which opens up a browser leading to a site. Is there anyway for Flash to detect when the user is idle and that when it happens, it goes back to the flash movie? Thanks for your time.

[tip] Mouse L/M/R Button Detection
Hi guys.


The following script can be used to check which mouse button has been clicked.. including the mousewheel button (middle button).

It also detects the right mouse button, but I'm not sure that would be very useful because the Flash context menu appears.

Anyway, have a play with this :


ActionScript Code:
onEnterFrame = function() {
    if(ASnative(800,2)(1)) trace("1 : Left button down");
    if(ASnative(800,2)(2)) trace("2 : Right button down");
    if(ASnative(800,2)(4)) trace("4 : Middle button down");
};

Mouse Detection Gallery
im trying to create an image gallery similar to the one seen here http://www.flashimagegallery.com/pics/artwork/

does any one know any good tutorials or can atleast get me running off on a good start on how to approach something like this? i know it works with the _xmouse and _ymouse coords...what i want to know is how the got the coords of the picture to align with the mask coords as the mouse moves around. can anyone help?

Mouse Detection Query
Hi guys,

I have a particular action (a tween) which Id like to roll out when the mouse is over a particular square on the stage. When the mouse moves off that square, i want it to roll back in.

Thing is, I want to do it without buttons, or at least I want to do it without the mouse cursor switching to the overstate. An invisible button, if you like.

I know its easy to hide the mouse and start dragging a gif or some such on rollover, but I've always hated using that method, because ive found if you move the mouse fast enough, flash sometimes 'forgets' to drag the image; there's a dead-spot, so to speak.

ideally I want to do it by detecting the mouse co-ordinate, but im stumped as to how to do it, any ideas guys? I know how to check for a single mouse co-ordinate, but how do you check for both the x and y co-ordinate at the same time, ie, how can you detect when the mouse is within a square?

hope you can help guys,

s.

Help With Set Interval And Mouse Detection
I want to tell a movieclip to go to frame 46 (after a 5 second delay) if no mousemovement is detected. I'm not really sure how to do this. Here's what I have now, please let me know if you have a solution:


ActionScript Code:
onClipEvent (mouseMove) {
    recentMove = true;
}
onClipEvent (enterFrame) {
    if (recentMove != true) {
        setInterval(gotoAndPlay(46), 5000);
    }
}


Note that this code is placed on an empty movieclip in the timeline of the movie I am trying to control in this manner.

Thanks in advance for any help you can provide!!!

Problem With Mouse Detection
Hi all.. I have several stacked movieclips, and they fade in and out, when you rollover them there is a title that gets changed.. the problem is that if the rollover stays in place the new rollover state doesn't launch. I'm trying to work around that by checking for the position of the mouse and holding the place of the animation in a variable, then kicking off the right title.. it isn't working.. here is the code that is being naughty:


Code:
function changeProductName(){
if (_root._xmouse > item_button._x && _root._xmouse < item_button._x + item_button._width && _root._ymouse > item_button._y && _root._ymouse < item_button._ymouse + item_button._height){

if(animationLocation == 1){
productName.gotoAndPlay("product1");
}
if(animationLocation == 2){
productName.gotoAndPlay("product2");
}
if(animationLocation == 3){
productName.gotoAndPlay("product3");
}
if(animationLocation == 4){
productName.gotoAndPlay("product4");
}
if(animationLocation == 5){
productName.gotoAndPlay("product5");
}
}
}
it never gets inside the first "if" statement.

Mouse Movement Detection Timer
I had asked about a timer that can detect if the mouse has been moved for a certain amount of time and if not it would go back to the first frame (example=intro) , i had got the script of a fellow flash designer here but as my computer crashed i lost the fla file. if that person could get in contact with me that would be great. or if anybody else has the script. thanks in advance for any help.

RollOver Detection While Mouse Is Pressed?
Hello,

I found out that flash doesn't recognize a rollOver event while your mouse button is pressed.
The thing is, I can't do it with hitTest either, because too many mc's have to be tested all the time, so the pc can't keep up.

Does anyone has an alternate solution and wants to help me out?

Thank you,

[AS1] Mouse Speed Detection Problem
I've been facing this problem for years and I finally decided to try and find the answer to it. I use something like this code to detect the speed of the movement of a dragged object


PHP Code:



if (!go) {
        this["position_"+i] = this._y;
        i++;
        if (i == 3) {
            i = 1;
        }
        delta_y = this.position_2-this.position_1;
    }




This way I can find in what direction the mouse vertically has moved and at what speed. The problem is that every once in a while the speed will be in the opposite direction. What do people use to detect the direction of the movement of the mouse?

Moving A Movieclip Using Mouse Detection
Hi,

Does anybody have script that can move a movieclip in all directions depending on where the mouse is moved.

ie. when the cursor is moved to the right, the clip moves to the left etc ( kind of like a scrolling mechanism for scrolling a huge image that cannot all be seen at the same time (in a mask)).

Any help much appreciated

Help With Mouse Movement Detection And Timing
I want to tell a movieclip to go to frame 46 (after a 5 second delay) if no mousemovement is detected. I'm not really sure how to do this. Here's what I have now, please let me know if you have a solution:

code:
onClipEvent (mouseMove) {
recentMove = true;
}
onClipEvent (enterFrame) {
if (recentMove != true) {
setInterval(gotoAndPlay(46), 5000);
}
}


Note that this code is placed on an empty movieclip in the timeline of the movie I am trying to control in this manner.

Thanks in advance for any help you can provide!!!

Detection And Showing Mouse Proximiy
[IMG]Hi All
hope you can help me in my college project
its all about detecting how close the mouse is from multiple movie clips
as the user moves the mouse around the screen when he comes close to a movie clip the movie clip plays, say there are five movie clips on the screen the mouse will always be closest to one movie clip therefore that movie clip would play(could be a simple 2 frame animation of it changing colour)
also a pictorial meter that corresponds to a movie clip would increase as it got closer. I think it could be done with simple buttons but the breif is asking for mainly action scrip and it has got me stumped, i have some code for detecting if the mouse is close but am a bit stuck on the meter side of things
hope someone can help,
regards and thanks
bing

Mouse Detection+circle Movement
hey all,
I am trying to get a circle with a dot to rotate to the position of the mouse when the mouse is over the circle

I am using this mouse detection code:


Code:
this.pos = 0;
this.vel= 0;
this.acc = 0;
_root.onEnterFrame = function() {
this.lastPos = this.pos;
this.lastVel = this.vel;
this.pos = _root._xmouse;
this.vel = this.pos-this.lastPos;
this.acc = this.vel - this.lastVel;
trace("Position:"+this.pos +", Speed:"+this.vel +", Acceleration:"+this.acc);
}
and i tried various if formulas but i can't get them to work as a peace of a circle instead of a square

I was wondering if someone knew a different approach or a way to get the if formulas to work?

Follow Mouse Collision Detection
Ok ,
I have two objects as movieclips, and they both have a script on to follow mouse, and the angle of the mouse (the objects turn to the mouse).

I need to know how to make them not overlap when they come into contact with each other,
I have been able to detect the collision between the two, but i cannot make them 'bounce' off each other when they collide.
heres the script to detect the collision:
(the two objects are called letter, and letter2

letter_x = getProperty("/letter", _x);
letter_y = getProperty("/letter", _y);
letter2_x = getProperty("/letter2", _x);
letter2_y = getProperty("/letter2", _y);
letter_h = getProperty("/letter", _height)/2;
letter2_h = getProperty("/letter2", _height)/2;
letter_w = getProperty("/letter", _width)/2;
letter2_w = getProperty("/letter2", _width)/2;
distance_x = letter_x-letter2_x;
distance_y = letter_y-letter2_y;
area = (Number(letter_h)+Number(letter_w))*(Number(letter 2_h)+Number(letter2_w));
if (Number(Number(distance_x*distance_x)+Number(dista nce_y*distance_y))<=Number(area)) {

?????????

Please please help, !!!

Mouse Detection Image Gallery
m trying to create an image gallery similar to the one seen here http://www.flashimagegallery.com/pics/artwork/

does any one know any good tutorials or can atleast get me running off on a good start on how to approach something like this? i know it works with the _xmouse and _ymouse coords...what i want to know is how the got the coords of the picture to align with the mask coords as the mouse moves around. can anyone help?

Play Movie On Mouse Detection
Hi
Hope you can help
I have a movie clip with 40 frames and what i am looking for is some script to play the movie to a certain frame dependent on how close the mouse is to it
ie, mouse 100 pixels away- movie plays to frame 1
mouse 5 pixels away - movie plays to frame 40
I want about 5 movie clips on the stage all acting in accordance to the mouse position
is this possibe,
hope someone can help
regards
bing

Continuous Detection Of Mouse Rollover Over A Mc
Hi,

I want detect when the mouse is over a mc and while is there, I want do something like change continuously the position of another movie clip.

Any ideas where to start

Thx

Mouse Detection Outside Flash Window
I have a moving banner with some pictures in it. If you move your mouse to the left the speed to the left increases, and if you move to the right the speed increases in the opposite way.

an example can be found here:


The problem is that if you leave the window flash remembers the last _xmouse position. I want that the speed is reset to a default value when you leave the Flash window.

I've tried to make this with a border of 5 px and a hittest to test if you are leaving the window, but with the fps set to 30 this is to slow if you leave the window to fast.

how could i solve this problem best?

source code:
frame1:

Code:
//namenlijst
_global.namesArray = Array( "angela_hubel",
"annelies_planteijdt",
"beate_weiss",
"cecile_van_eeden",
"elly_vos",
"laura_bakker",
"monika_gloss",
"sabine_ring-kirschler",
"site_falkena",
"stephen_greenstein"
);

//inladen namen
arrayLength = namesArray.length - 1;
_global.pictures = namesArray.length
arrayLengthLast = namesArray.length - 10
i = 0;
j = 10;
xDistance = 0;
k = 0;

while(arrayLengthLast <= arrayLength)
{
tmp = _root.theBar.createEmptyMovieClip(namesArray[arrayLengthLast]+"v", j);
tmp.loadMovie(namesArray[arrayLengthLast]+".jpg");
tmp._x = xDistance;
arrayLengthLast++;
j++;
xDistance = xDistance + 90;
}

while(i <= arrayLength)
{
tmp = _root.theBar.createEmptyMovieClip(namesArray[i], j);
tmp.loadMovie(namesArray[i]+".jpg");
tmp._x = xDistance;
i++;
j++;
xDistance = xDistance + 90;
}

while(k <= 9)
{
tmp = _root.theBar.createEmptyMovieClip(namesArray[k]+"a", j);
tmp.loadMovie(namesArray[k]+".jpg");
tmp._x = xDistance;
k++;
j++;
xDistance = xDistance + 90;
}

// theBar goed zetten
_root.theBar._x = -900;
source code:
frame2:

Code:
if(_xmouse > 5 && _xmouse < 895)
{
if(_root._xmouse <= 449)
{
xAsV = _root._xmouse - 450;
speedV = -1*(xAsV/40) + 1;
_root.theBar._x = _root.theBar._x - speedV;
}

if(_root._xmouse >= 450)
{
xAsA = _root._xmouse - 450;
speedA = (xAsA/40) + 1;
_root.theBar._x = _root.theBar._x + speedA;
}
}
else
{
_root.theBar._x = _root.theBar._x + 1;
}

if(_root.theBar._x < -90*(pictures)-900 )
{
_root.theBar._x = -900;
}

if(_root.theBar._x > 0 )
{
_root.theBar._x = -900;
}


for(i = 0;i < pictures;i++)
{
tmp = _root.theBar[namesArray[i]];
}
trace(_xmouse);
source code:
frame3:

Code:
gotoAndPlay(2);

Mouse Follow With Collision Detection
I've had a search through the tutorials and through these forums and I haven't found a solution to my problem yet.

I have a boat which will follow my mouse, which I have got working via the tutorial situated at: http://www.kirupa.com/developer/mx/followease.htm

That's easy enough.

My problem is not making the boat stop if it collides with another movie. You can view what I currently have here:

http://www.kevehdesign.co.uk/headspa..._change_2.html

and the fla is located at:

http://www.kevehdesign.co.uk/headspa...e_change_2.fla

If you look at this movie you will see the boat following your mouse, and I've inserted a basic island on to the stage. What I want to happen is that if the boat touches the island, it stops. so for example if you were moving your mouse right to left across the island, the boat would stop on the right hand side of the island, but if you moved your mouse back to the right, it would move away from the island and follow your mouse.

I'm not too bothered about it detecting certain areas of the boat, the center point is fine.

Does anybody know how to do this, or know of a tutorial somewhere which is similar?

Thanks.

How Do I Use Mouse Detection Inside A Class?
I'm writing a class to create a menu for my new website and I have a question:

If I create the object with AS, how can I attach the classic on(over) etc... to the object I'm creating?

Do I have to extend MovieClip or something like that?

my class is


Code:
class menuBar{
public function class(mc:MovieClip) {

draw(mc, Math.round(Stage.height*15/100), Stage.width, 0, Stage.height-Math.round(Stage.height*15/100));
}
private function draw(root:MovieClip, h:Number, w:Number, myX:Number, myY:Number) {
root.beginFill(0x000000);
root.moveTo(myX,myY);
root.lineTo(w,myY);
root.lineTo(w,myY+h);
root.lineTo(myX,myY+h);
root.lineTo(myX,myY);
root.endFill();
}

}
and in the main there is only


Code:
var newMenu:menuBar = new menuBar(mcMenu);
where mcMenu is a MovieClip that contains the menu. How can I make the menu reacting to the mouse?

Mouse Coords Detection Without OnClipEvent
MX04

I have an application where I need to detect if the mouse is less than 200 px from the left sie of the screen, then play an animation... Once the mouse is moved back out of the 200 px area I want the animation to reverse.

I'm using the Tween Class for animation and have been messing around with onclipevents with no luck like:

onClipEvent (enterFrame) {
if(_xmouse <= 200)
{
_root.theSwitch = "on";
}else{
_root.theSwitch = "off";
}

if(_root.theSwitch=="on")
{
trace("on")
}
}

(This has been dumbed down)

This will obviously produce a million "on" traces when the mouse is over there - what is the best method for detecting the change once, setting a variable, then playing the animation?

Thanks in advance!

Mouse Detection Image Gallery
help!!

im trying to recreate an image gallery as shown here:
http://flashimagegallery.com/pics/artwork/

basicaly when your mouse moves the image adjusts based on the ratio of the viewing area.

the setup is basicaly a viewing area mc i have called (mMask) and a picture, mc that lays behind it called pichold. these two mc's are nested within a movie clip called viewgall. im working on this on the side to then bring into another .fla when finished. these heres what i have so far for the code:


Quote:




init();
function init():Void {
//pic = attachMovie("pichold", "pichold", 0);
picrangeX = (pichold._width-mMask._width)/2;
picrangeY = (pichold._height-mMask._height)/2;
centerX = mMask._width/2;
centerY = int(mMask._height/2);
pichold._x = centerX;
pichold._y = centerY;
}
function onEnterFrame():Void {
var dx:Number = _xmouse-centerX;
var dy:Number = _ymouse-centerY;
var angle:Number = Math.atan2(-dy, -dx);
var speed:Number = (Math.sqrt(dx*dx+dy*dy))*.05;
var vx:Number = Math.cos(angle)*speed;
var vy:Number = Math.sin(angle)*speed;
if (pichold._x>=(centerX+picrangeX)) {
pichold._x = centerX+picrangeX;
}
if (pichold._x<=(centerX-picrangeX)) {
pichold._x = centerX-picrangeX;
}
if (pichold._y>=(centerY+picrangeY)) {
pichold._y = centerY+picrangeY;
}
if (pichold._y<=(centerY-picrangeY)) {
pichold._y = centerY-picrangeY;
}
pichold._x += vx;
pichold._y += vy;
}




im wondering if i have to take into account the stages width and height at all to get this to work properly. the x and y coors for the picture are all screwed up and i dont know why?!?

im still learning the ropes here...can anyone take a look at this and help me out?

Trigger An MC Event W/ Mouse Detection?
Is there a way to trigger a movie clip event (say play certain frame label) when the mouse moves over a certain area of the flash canvas horizontally?

PrevFrame() With Mouse Collision Detection
hello all,

i have successfully created scripts with prevFrame() that work, thanks to Kirupa's tutorials. however, when i try to use "mouse collision detection" with prevFrame(), it will not work.

i added a mouselistener object to detect if my mouse hits the purplebar i have on stage:
Code:
this.onEnterFrame = function() {
if (rewind == true) {
//if rewind switch is set to true play backwards
prevFrame();
// play backwards
}
};
// create a mouse listener object.
var mouseListener:Object = new Object();
/* every time the mouse cursor moves within the SWF file,
update the position of the crosshair movie clip instance on the Stage. */
mouseListener.onMouseMove = function() {
if (purplebar.hitTest(_xmouse, _ymouse, false)) {
rewind = false;
play();
} else {
rewind = true;
}
};
Mouse.addListener(mouseListener);
i've tried putting trace in my function to test my mouse detection is working and all. help please?!

I've uploaded the .fla file. Will appreciate if you can take a look at it. Thanks in advance!

[AS1] Mouse Speed Detection Problem
I've been facing this problem for years and I finally decided to try and find the answer to it. I use something like this code to detect the speed of the movement of a dragged object


PHP Code:



if (!go) {
        this["position_"+i] = this._y;
        i++;
        if (i == 3) {
            i = 1;
        }
        delta_y = this.position_2-this.position_1;
    } 




This way I can find in what direction the mouse vertically has moved and at what speed. The problem is that every once in a while the speed will be in the opposite direction. What do people use to detect the direction of the movement of the mouse?
:confused:

HELP SetInterval And Mouse Detection Issues
Hi All,

I have this code on my first frame and within several movie clips. The goal is to have my movie loop through various clips when the mouse is inactive. The clips have animation in them that "slide" them in and out so I need to have this action within each clip as well as on the initial frame of the movie. Right now, this is very close to what I want, the only problem is that if the mouse is moved once the "detection" stops working. However, if I remove the "clearInterval" on mouseMove, I cannot seem to keep the setInterval from each frame it's on from running in the backround when it shouldn't be.

My only ideas have been to put the actual setInterval function on some kind of timer that's tied to mouse movement or somehow embed it in a movieclip that's actually removed/added based on mouse activity.

ANY ADVICE WOULD BE GREATLY APPRECIATED! THANkS SO MUCH!

Here's my code:

Code:
loadVariablesNum("launchlinks.txt", 0);
var nMouseCheck:Number = setInterval(mouseCheck, 15000);
var oldMouseX:Number = _xmouse;
var oldMouseY:Number = _ymouse;
function mouseCheck():Void {
if (oldMouseX+oldMouseY == _xmouse+_ymouse) {
gotoAndPlay(2);
clearInterval(nMouseCheck);
Mouse.hide();
} else {
oldMouseX = _xmouse;
oldMouseY = _ymouse;
}
}
_root.onMouseMove = function() {
Mouse.show();
clearInterval(nMouseCheck);
};
stop();

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