dcsimg
A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Scrolling MC with Mouse Over

  1. #1
    Junior Member
    Join Date
    Sep 2000
    Posts
    4
    Hello -

    I am trying to make a Movie Clip (MC) move when the user activates one of four buttons (up/down left/right). I need the user to Mouse Over a button to activate a smooth scroll... Let's say the MC should move 40px every 20 miliseconds in the correct direction.

    I am having a terible time figuring out a Loop that will Start on mouse over and stop on the mouse out.

    Any bright ideas?

    Thanks so much!

    -A.J. Greenlee

  2. #2
    Senior Member
    Join Date
    Jun 2000
    Posts
    1,180
    Hi..
    Add the following code to the MC you want to control:

    onClipEvent (enterFrame) {
    this._y+=_root.dirY;
    this._x+=_root.dirX;
    }

    Now add the code to the buttons that control directions:

    Up:
    on (rollOver) {
    dirY=-5;
    }
    on (rollOut) {
    dirY=0;
    }

    Down:
    on (rollOver) {
    dirY=5;
    }
    on (rollOut) {
    dirY=0;
    }

    Left:
    on (rollOver) {
    dirX=-5;
    }
    on (rollOut) {
    dirX=0;
    }

    Right:
    on (rollOver) {
    dirX=5;
    }
    on (rollOut) {
    dirX=0;
    }

    Hope this helps.

  3. #3
    Junior Member
    Join Date
    Sep 2000
    Posts
    4

    How to implement a check?

    Thank you, that worked perfectly.

    However I tried to add a IF/ELSE statment to make sure the box does not go beyond my boundry and it did not work.

    How can I check a varible in my Main Movie (_root.TopBoundry) to ensure that the MC does not go past the point?

    Thanks so much!

    -A.J.

  4. #4
    Senior Member
    Join Date
    Jun 2000
    Posts
    1,180
    Hi..
    You'll have to position your MC precisely, then you can use:

    onClipEvent (enterFrame) {
    this._y += _root.dirY;
    this._x += _root.dirX;
    if (this._x>=300) {
    this._x=300;
    } else if (this._x<=100) {
    this._x=100;
    } else if (this._y<=100) {
    this._y=100;
    } else if (this._y>=300) {
    this._y=300;
    }
    }

    Good luck.

  5. #5
    Junior Member
    Join Date
    Aug 2000
    Posts
    24
    Marx, Thanks, Ive been posting message recently asking what you answered here..Appreciate it..

    One thing would you know what can be done to also zoom in and out the movie clip..ie to get a close up of the movie clip..

    I only used the right and left part of your code, to move the movie right-left, maybe you would know how moving the mouse up and down would zooom in and out?

    Thanks in advance.

  6. #6
    Senior Member
    Join Date
    Jun 2000
    Posts
    1,180
    Hi..
    You can use the same priciples as before except you use the xscale & yscale properties:

    1) On the MC:

    onClipEvent (enterFrame) {
    this._yscale += _root.rateY;
    this._xscale += _root.rateX;
    }

    2) Zoom in:

    on (rollOver) {
    rateX = 5;
    rateY = 5;
    }
    on (rollOut) {
    rateX = 0;
    rateY = 0;
    }

    3) Zoom out:

    on (rollOver) {
    rateX = -5;
    rateY = -5;
    }
    on (rollOut) {
    rateX = 0;
    rateY = 0;
    }

    If you wanted to do it by mouse position then play about with the following code:

    onClipEvent (enterFrame) {
    this._yscale=(100-(_root._ymouse/4));
    }

    Hope this helps.

  7. #7
    Junior Member
    Join Date
    Aug 2000
    Posts
    24
    Ok, tried it it works but not getting the results i want.. maybe ill show you what i did so far.

    see http://www.braintoaster.com/portfolio.html

    i actually have 2 buttons, (one for moving right and one for left) each button is behind the movie (so its hidden) and its half the screen, so if you move right it goes right, if you move mouse to other half of page it goes left.. i want to zoomin and out at the same time it can move left and right..

    What i tried after your post (not visible online): i added two button (top half & bottom half of screen) it zoomed but didnt scroll sideways too well, as well it shrunk beyond the original size.. i want it to zoom to users can get closer looks but then zoom out to original size.. is there a better way to do it.. (im sure there is)

    thanks in advance.

  8. #8
    Senior Member
    Join Date
    Jun 2000
    Posts
    1,180
    Hi..
    Similiar principles again:

    1) On MC:

    onClipEvent (enterFrame) {
    this._yscale += _root.rateY;
    this._xscale += _root.rateX;
    if (this._xscale==150) {
    _root.rateX=0;
    if (this._yscale==150) {
    _root.rateY=0;
    }
    }
    if (this._xscale==50) {
    _root.rateX=0;
    if (this._yscale==50) {
    _root.rateY=0;
    }
    }
    }

    2) Zoom in:

    on (rollOver) {
    rateX = 5;
    rateY = 5;
    }
    on (rollOut) {
    rateX = 0;
    rateY = 0;
    }

    3) Zoom out:

    on (rollOver) {
    rateX = -5;
    rateY = -5;
    }
    on (rollOut) {
    rateX = 0;
    rateY = 0;
    }

    You'll need to set the scale in the MC code to match your requirements.

    Good luck.

    PS: If your want to zoom to the original size then set the scale properties to '100%'.

  9. #9
    Junior Member
    Join Date
    Aug 2000
    Posts
    24
    How would you suggest i make buttons (that are not visible) to do the above (with he zoom), what i tired was to create a top half scrren button and bottom half but it kind of conflicted with the right left ones..

    i want it to seem like no buttons are there (hence they are hidden behind the MC) and mouse movement up and down does the zooming s well at the same time they can scroll right or left... and ..

    how do i set the zoom out (shrinking) to STOP and no go further than its original size. where do i set the zoom to be "scale properties '100%'."

  10. #10
    Senior Member
    Join Date
    Jun 2000
    Posts
    1,180
    Hi...
    You can set an if statement using the xscale and yscale properties to set the scale to 100%.
    In the above example I used 50, change it to 100.

    Good luck.

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