onMouseMove

i want the playhead to shift a frame each time i move my mouse over a certain area, but the following code is making this happen when i move my mouse anywhere on the stage

onClipEvent (mouseMove) {
_root.myClip.nextFrame();
}

can i specify coordinates?

i tried using rollOver instead, but of course, this only moves the playhead once and i have to roll out of teh object in order to create a new rollOver event

as always, thanks

Try:

onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true) {
_root.myClip.nextFrame();
}

Haven’t tested it yet - should work.

It will work on a movie clip. So put whatever you want the mouse to be over, in a movie clip, then give the mc the above actions.

yeah that should work…you didn’t have anything to stop it from doing the action when the mouse wasn’t over :slight_smile:

how about

onClipEvent (mouseMove) {
if (_root._xmouse>200) {
_root.myClip.nextFrame();
}else if (_root._xmouse<100){
_root.myClip.previousFrame();
}
}

or something to that effect.

I don’t think this is an optimal way of doing this effect though… I guess I would need to know how this is being used before I could come up with something that might work well. mouseMoves can be nice because they free up processor power from doing enterFrame effects, but they are cumbersome in how they operate.

I guess my questions would be:
do you want it to only go one frame per time it’s placed on the spot?
and
is the spot an area on the stage, or just a matter of left of center/right of center kind of thing?

just my two cents…


theMovie.onRollOver = function(){
   this.onMouseMove = this.nextFrame;
}

theMovie.onRollOut = function(){
   this.onMouseMove = null;
}

edited to make shorter

nice… does it work in 5.0 or MX or both?

mx only, i’m afraid.

the event engine is one of my favourite additions…

I wish you guys would remember to put that in your posts. :slight_smile:

It is REALLY nice to see how much smaller the coding is becoming in the new version of Flash though.

ok,

flex’s code did the trick:
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true) {
_root.myClip.nextFrame();
}

and david took it a stage further with the addition of prevFrame(), which i hadn’t thought about!!

what i want to do is this: i have a ‘viewing’ area on the stage, where i’m going to insert a clip containing a sequence of images that, when run one after the other, give the impression of video-like movement

i’m going to place an invisible button over that viewing area and insert the code in question, so that when the cursor moves over the button… you get the video-motion

i saw this in a great site (i can’t find the url or i would post it) and i fell in love with the effect

thanks for all that
:slight_smile:

PS sbeener’s code is very compact!! i’ll have to meddle with it
:slight_smile:

yeah… if that’s what you’re trying to do, I’d definitely ignore my post and go with the enterFrame method discribed by Flex. I was just trying to save you some processor power. The enterFrame method though will provide smooth frame by frame, even if the person stops moving their mouse. (onMouseMove only works when the mouse is actually in motion)

glad you got it working… sounds like a neat effect. Please try to remember to give us a link to check it out once you’ve got all the bugs out. :slight_smile:

ok, i’m still having a few snags… i spoke too soon (before i tried the code)

here’s a link to what i’m working on:
http://www.alt-student.co.uk/flash/1.htm
(that’s not me, btw - it’s my son)
:slight_smile:

the ‘movie’ is a sequence of pics with a gotoAndStop(1); on the last frame (so you see it run once on load)

the code on the movie instance is:

onClipEvent(mouseMove){
if (this.hitTest(_root._xmouse, _root._ymouse, true)){
_root.myClip.nextFrame();
}
}

the prob is that the movie only plays forward

david: i tried your code:

onClipEvent (mouseMove) {
if (_root._xmouse>200) {
_root.myClip.nextFrame();
}else if (_root._xmouse<100){
_root.myClip.previousFrame();
}
}

it does what i need it to do, but i don’t know how to work out the x and y coordinates of my movie (so that it works properly)

and finally, here’s the link to the site where i saw the effect (i found the url)

http://www.yulia-nau.de/eng.htm

I modified an image scroller I did for some at Kirupa. This should work:

EDIT: Changed the fla brought the boundaries closer.

It’s the same as the code David posted, just in onClipEvent(enterFrame). It moves the animation forward while the mouse is held in a certain place, and moves the animation back, if held in another. If you wanted to the animation to play when the mouse was dragged - use David’s code (the on mouse move).

got it!

i woke up this morning, stared at the ceiling and thought: info panel, cente/left grid…

i don’t know why this eluded me last night - ok, so the coordinates are no prob

cheers flex for the zip: it’s interesting to see how somebody else does things - i.e. i thought of using a video file and placing a stop action on each keyframe (as opposed to using a sequence of images) but i wondered whether that was a good way to do things

i suppose the video file will be much bigger but it would be interesting to see how it responds - you might get some blurring between stops in framesm but that ight look good (i’ll give it a try later)

did you check that site out?

actually, having tried the code and looking back at the original effect i can see that i misunderstood some of the mechanics

ok - this might be voodoo and maybe a different object with the right methods is required, but this is the functionality i was after:

===
if the mouse moves to the right, then nextFrame();

if the mouse moves to the left, then prevFrame();

please don’t think the previous stuff was a waste of time! it’s given me the foundation to see this far!
:slight_smile:

see http://www.kirupaforum.com/showthread.php?s=&threadid=6435

:slight_smile:

very nicely written - we often forget ‘how we work’ when busy trying to solve ‘how things work’

at my level though, i’d be asleep for most of the day!
:stuck_out_tongue:

i shall work/sleep on it

funnily enough, i’m finding that the more time i spend sitting around visualising a site, the less time i spend at the PC

cheers

that is very true too. my current site, animation.centerspin.com consists of:

32 3/5 cards with notes.
1 steno of various tested and partial code.
1 steno containing names of movie clips, variables, arrays, xml docs, text docs, etc
42 sheets of white scrap paper with sketches of sections or clips.
3 sheets of white paper containing a flow chart.

And that site is small compared to a real commercial site. I can only imagine how complex that must get.

I was thinking of somehow (I was trying to figure it out last night) using getTimer() to check the current _xmouse to the _xmouse 0.5 or 0.25 seconds ago and if it was > x nextFrame(); and if it was < x prevFrame();.