A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: how to set restraint when panning mc left and right

  1. #1
    Junior Member
    Join Date
    Sep 2002
    Posts
    22

    how to set restraint when panning mc left and right

    Please help me.
    I have scripted for a movieclip to pan left and right according to the mouse but i want it to stop when the side of the movieclip reached the side of the mask. That is i don't want to see the background behind, i want the movieclip to stop panning exactly before the bg reveals. Please review my source file and tell me what's wrong. thanx

    [FILE]

    i think this is the part that went wrong

    myClip = movie1;
    if (myClip._x< -119) {
    stopDrag();
    } else {
    startDrag("drag", true);
    }
    xposition = getProperty("movie1", _x);
    movie1._x += (xposition+drag._x)/((100-speed)*-1);
    movie1._x += (xposition+drag._x)/((100-speed)*-1)+num;
    movie1._x += (xposition+drag._x)/((100-speed)*-1)-num;

  2. #2
    Junior Member
    Join Date
    Nov 2001
    Posts
    7

    i cant see you source file for some reason

    but, id do it like this:

    Have free frames.
    FIRST FRAME
    if so you need to set somes stoppers before the loop starts to say when the mc should stop and where the centre (where it starts) is.

    center = 250;
    reelPos = mcname._x;
    leftStop = -250;
    rightStop = 500;

    SECOND FRAME

    Put in the code the calculates where the mc is and how far from the mouse it is. And finally moves it appropriatly.

    if (_ymouse>1) {
    photoSpeed = (_xmouse-center)/10;
    photoPos = Math.round (photoPos+photoSpeed);


    if (photoPos<leftStop) {
    photoPos = leftStop;
    }
    if (photoPos>rightStop) {
    photoPos = rightStop;
    }
    photo._x = photoPos;
    }

    THIRD FRAME
    Loop it! so it keeps calculating and moving the mc. (label frame two 'loop')

    gotoAndPlay ("loop");

    sorry about the spelling and i hope this is what you wanted.

  3. #3
    Junior Member
    Join Date
    Sep 2002
    Posts
    22
    thanx so much for your help! it's works perfectly!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center