Link to home
Start Free TrialLog in
Avatar of deominate
deominate

asked on

help playing frames based on _xmouse


Just started learning flash and actionscript two weeks ago.
sorry if this question is too easy.
I'm trying to play frames when the mouse moves left or right.
when the mouse moves right I play the next frame,
subsequently when the mouse moves left I play the previous frame.
Only problem is... I only want to play frames when the mouse is moved inside the movie.
I tried to use an if that specifies the x bounds of the movie...
but don't know what I'm doing...
Can you help with this code?
or suggest an easier way of accomplishing this?

CODE BELOW--

stop();
//WORKS only over entire page
//need it to only work between x values
var point = 0;
var newpoint = 0;
// x values of the movie
if (_xmouse <= 435 && _xmouse >= 114){
     point = _xmouse;
     _root.onMouseMove = function (){
          newpoint = _xmouse;
          // set max frames
          if(point > newpoint && _root.nextFrame() != 15){
               gotoAndPlay(_root.nextFrame());
               point = newpoint;
          }
          else
          // Set min frames
               if (_root.prevFrame != 0){
                    gotoAndPlay(_root.prevFrame());
                    point = newpoint;
               }
       }
}


I only have 75 points available...Sorry.
Avatar of rascalpants
rascalpants
Flag of United States of America image

the error looks like it is in this line:

if(point > newpoint && _root.nextFrame() != 15){


because you are setting point and newpoint to the _xmouse, then will always have the same value...


I don't think you want that right?


rp
Avatar of henryww
henryww

don't be sorry ... for what? 75pts is enough, cos u have given 100% of what u have... how nice :)

i am not sure how u will like it exactly and not quite understand ur code.

anyway, u will have to have something to monitor the _xmouse continously somewho, but to "play" the prevFrame() ... u can't, u can only stop there ..


if u are using MX it will quite easy
myClip.onMouseMove = scrollFrame;
myClip.onRollOver = scrollFrame;

function scrollFrame() {
     if (myClip._xmouse > WHERE_ON_UR_MOVIE_U_WANT_IT_TO_MOVE) {
          myClip.prevFrame();
     } else {
          myClip.nextFrame();
     }
}

change the if statement a little u can have it stop while in the middle of the movieclip ...
Avatar of deominate

ASKER

Its not that because "point" is set outside of the mouseMove function...right?
My nextframe and prevframe work well,
its just that
I don't want anything to execute when the mouse is located outside of x value 114 or 435
when I test the movie, no matter where I am on the screen the movie executes, I only need it to execute when the mouse is moved over the movie.

The desired effect can be seen on
www.alexhoerner.com when moving over the girl on the left.
I'm probably going about this all wrong.
i know what u are talking about ...
i have seen this lastnight ... man it took a long time to load so heavy ...

it is not hard at all and it is not going continously ...
if u have a series of photo which will move & look like that site, send it to me, and i can make a sample for u ... it is not hard, but not easy for beginners ...

i like that site, very clever in the making ... but ... too much too heavy and nothing much to see except that effect.
btw ... where did u guys found these sites ...?
i have a friend sent that exactly link to me last night and asked me if i could do it ...
I found it through...
http://www.favouritewebsiteawards.com/home.html

I'm still trying to make that code work that you suggested, but I am at a loss.

Like I posted I am brand new to this.
Is there any way I can get in touch with you in the future without going through ex-ex?
ASKER CERTIFIED SOLUTION
Avatar of henryww
henryww

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial