A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: A mask following the mouse???

  1. #1
    Junior Member
    Join Date
    Aug 2002
    Posts
    9
    Hi,

    At the moment I am using this script so a movieclip follows the mouse:

    onClipEvent (enterFrame) {
    targetX=_root._xmouse;
    distX=targetX-shapeX;
    shapeX=Math.round(shapeX+(distX/4));
    _parent._x=shapeX;
    }

    However, what I am trying to acheive is the effect that http://www.studiocmd.com/corporate/corpindex.htm have with the fish on the main page. I take it they used a mask for this effect, but can't get a mask to work with this script. Any ideas??????

    Thanks

    Barry

  2. #2
    Didn't do it. japangreg's Avatar
    Join Date
    Mar 2001
    Location
    \o/ |o| |o_ /o\
    Posts
    784
    Hey, Barry. This question comes up from time to time, and it's what first brought me to Flashkit. Please see the following thread I posted to only a little while ago; it may help answer this question.

    http://board.flashkit.com/board/show...hreadid=355593

    If this doesn't help, post here again and I can give you more specific descriptions.

    hth
    japangreg

  3. #3
    Junior Member
    Join Date
    Aug 2002
    Posts
    9
    Hi,

    I tried your first idea in the other thread, but I can't seem to get it right. The mask flashes continually and the mask is not lined up with the image. Also it doesn't always follow the mouse. Have you got an email address I could send the .fla file to, so you could see where I'm going wrong?

    Thanks for your help

    Barry

  4. #4
    Didn't do it. japangreg's Avatar
    Join Date
    Mar 2001
    Location
    \o/ |o| |o_ /o\
    Posts
    784
    Hey, Barry. If you want to email me, just click on the "Email" button below any of my posts.

    The reason the mask is flashing is due to the number of frames you used for the motion-tweened mask and the frame rate of your movie. Try to tween it over a larger number of frames and raise the fps settings. It probably doesn't align proerly because the width of the mask element is not being taken into account (don't think I raised that point on the other thread - sorry)

    For the most basic example, if your movie is 100 pixels wide, and you mask is 20 pixels wide, then when the mask is stationary over the image at the left-hand side (before you tween it) it already covers 1/5th of the image. And when the mask is all the way to the right, it still covers 1/5th.

    When using this technique, the center-point of the mask element will correspond to the _xmouse position, so when the mouse is at 0, the mask element will be over the image displaced fully to the right. (sorry, couldn't think of a clearer way to say that) So if you began your motion tweening mask-element half-way off of the image and finished it half-off on the other end, it should work. If you aligned the mask-element with the edge of the screen, it won't and will appear off-set from the un-masked image (which isn't always a bad effect...)

    Sorry this is so confusing. I'm much better at explaining things in person than by text (I jump around a lot and flail my arms ) If you still don't understand, email me and I'll see what I can do.

    hth
    japangreg

  5. #5
    Senior Member
    Join Date
    Dec 2000
    Posts
    118
    Hey Barry, why not email studio:cmd ? They've always responded to me, just go tothe source.

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