Cool scroll

Does somebody know how to make a MC scroll like this?:
kriztal.com

…if you move your mouse up, the MC scrolls down, and if you move your mouse down, the MC scrolls up!

You can use this and change some of the vars around.

http://www.kirupa.com/developer/mx/infinite.htm

Oki, I ended up with this:

onClipEvent (load) {
    _x = 0;
    _y = 0;
    speed = 5;
}
onClipEvent (enterFrame) {
    endY = -(_root._ymouse);
    _y += (endY-_y)/speed;}

It works fine, but now to the next step: If I drag this MC to the stage it will scroll all the time, I know how to set a limit to the up/down scroll, but how do I define a “scroll area” - like on the kriztal site, here it only scrolls within a specefic area…

I think, if I understand, you need to make a masking layer over it so that it will only show a certain area. It’s at the end of the tut above.

no, the mask has nothing to do with that, the Infinite Menu is moving all the time!

Okay, I understand what you are saying now. I’m not sure what they are using, but I know how I would try to emulate it.

The scrolling part is a seperate swf - that’s why it only reacts when the mouse is in that area.

It’s basically one big MC that eases up a down. The speed and direction is in relation to the mouse coord (obviously). The infinate menu will go on forever, but the movement code is usable in what you’re doing.

I don’t know the code off the top of my head, but, I could try to make one and post the fla, if you want.

I don’t think that loading the movie into target would do thre trick, but I’ll give it a try!

And it would be NICE if you would give it a try to! :slight_smile:

This is harder that I formulated it in my head. I think I need to take a different approach than what I said before. Shoot!

I have to go to work so I will have to get back to you on this. This is what I tried and it didn’t work:

In the meantime, checkout the easing tut here and at
http://bit-101.com

That’s what I had originally planned and will do later.

Well, I guess it’s harder than I thought. I cant figure it out. I’m sorry. I tried a totally different way of doing it by editing the MC and putting the actions on a different layer so I could used
stop();s, but I can’t get it to reset after it stops. I guess it’s beyond me.

You may want to post again to see if someone else knows.
Sorry again, I’m too new.

thats OK mate - THX for trying!

Don’t know if you found a solution yet…but this is my code and it works.

You move the mouse left, it goes right and vice versa…however, it also has a speed factor…the closer you are to the center…the slower it gets…until it stops…when you move the mouse out to the side…left or right…it speeds up.

[AS]
onClipEvent (load) {
xcenter = 378;
speed = 1/20;
}
onClipEvent (enterFrame) {
var distance = (_root._xmouse-xcenter)-1;
if ((_root._xmouse>=245) and (_root._xmouse<=528) and (_root._ymouse>=274) and (_root._ymouse<=345)) {
_x += (distance
speed);
}
if (_x>0) {
_x = -647;
}
if (_x<-647) {
_x = 0;
}
}
[/AS]

Isn’t that going to loop the movieClip like the infinate menu? The problem I had was having the movieClip stop when you got to the end and start up again once you move the mouse again. I should give it a try again, too; I’ve learned a couple of tricks since March. (-:

hmmm,
forgive me if I don’t understand…

to answer your question, (I think)…
yes, it is using the basic infinite movie code…but with changes.

However, I have it masked…so…my coordinates…
[AS]
if ((_root._xmouse>=245) and (_root._xmouse<=528) and (_root._ymouse>=274) and (_root._ymouse<=345)
[/AS]

are within the range of my mask…so…if the mouse moves out of this range…the scrolling stops.

Once you move back into the range…it scrolls again…and depending on the location of the mouse (within this range), it either scrolls fast or slow.

Hope I’m not adding more confusion to all this…just thought I’d throw my 2 cents into …never know…it may help someone. :wink:

Yeah, I got that part, but if you go to the link that he has and put your mouse right above the little menu at the bottom, the list will ease to a stop even though the mouse is in the range. That’s what I can’t figure out. Or maybe it depends on where the mouse is in the range area - you know what, I think that’s it!! You change the endX in the easing tutorial formula to where the mouse is in that range!! I’m at work right now, but I gonna try that when I get home!!

Sentry- I’m not doubting you by any means - I just couldn’t figure out how it worked before and, even though I didn’t start the thread, I still want to know!! :P.

Ok, now i am a very, very, moooderately skilled flash user, so i hope i don’t offend anyone in this thread by posting what could potentially be a very stupid answer, since i don’t really know much of the code that you guys have been using. But sometimes it can be a very simple thing that ends up working. So…

What if you use the hitTest operation to define your hit area, so on your clipEvent (enterFrame) you could use:

if (hitTest(_root.mousex, _root.mousey, true)

Then would this make sense that if you mouse over the movie clip it will scroll, but if you mouse out the scrolling will be disabled? I apologize if this is ridiculous.

*Originally posted by drclare *
**[…]What if you use the hitTest operation to define your hit area, so on your clipEvent (enterFrame) you could use:

if (hitTest(_root.mousex, _root.mousey, true)

[…] **

drclare, you’re absolutely right! I’m the flash designer on the site - I followed the link from the referrals.

Put this on the movieclip you want to scroll (which is masked by the movieclip named ‘box’):

[AS]onClipEvent (load) {
friction = .2;
yWanted = 5;
}

onClipEvent (enterFrame) {
if (_parent.box.hitTest(_root._xmouse, _root._ymouse, false)) {
yWanted = -(((_parent._ymouse-15)/_parent.box._height)this._height) + 30;
}
yNow = _y;
delta = yNow-yWanted;
_y -= delta
friction;
}[/AS]

Hope this helps! :slight_smile:

Mads