-
I Like To Flash in Public ;)
hi,
i posted a question quite a while back about how to make scrolling movie slips so when ur mouse moves over it is moves left and right. a user gave me this code
Code:
onClipEvent (enterFrame) {
mousePosition = _root._xmouse;
maxRight= 688;
maxLeft = 100;
movement = 5;
zoneLeft = 300;
zoneRight = 488;
if ((this._x > maxLeft) && (mousePosition < zoneLeft)) {
this._x = this._x-movement;
}else if ((this._x<maxRight) && (mousePosition > zoneRight)) {
this._x = this._x + movement;
}
}
thing is. I didnt understand code fully and basically how do i make sure that once that the movie clip comes to the edges,it stops.and then u havbe to scroll back the other way...
At the moment it works in terms of it moves left and right but once i get to the edge of my mc it wont let me scroll back the other way.
Can Any1 help me out with this code?
Thanks
Blue Dragon
-
thing is. I didnt understand code fully and basically how do i make sure that once that the movie clip comes to the edges,it stops.and then u havbe to scroll back the other way...
At the moment it works in terms of it moves left and right but once i get to the edge of my mc it wont let me scroll back the other way.
Can Any1 help me out with this code?
Thanks
Blue Dragon
It works fine! I didnt get the problem you mentioned. when it reaches the edge, then you get the MC stop. when your mouse moves to <300 / >488 it start scroll to the other side again....
I can explain the idea to you...
Code:
onClipEvent(enterFrame) {
mousePosition = _root._xmouse; // get the mouse _x
maxRight= 688; // MC maximum _x
maxLeft = 100; //MC minimum _x
movement = 5; // each time the MC can scroll by 5 pixels
zoneLeft = 300; // when mouse is smaller then this value, MC scrolls left
zoneRight = 488; // when mouse is larger then this value, MC scrolls right
if ((this._x > maxLeft) && (mousePosition < zoneLeft)) {
this._x = this._x-movement;
stext="Left"; // useful in trace action
//in the case of 1. MC _x larger than 100 (MC on right screen) and Mouse is in "left scrolling active region", MC scrolls left
}else if ((this._x<maxRight) && (mousePosition > zoneRight)) {
this._x = this._x + movement;
stext="Right";
}
trace("MC _x :" +this._x +" Mouse _x :" + mousePosition+" Scroll :"+ stext); // add this trace action allows you to follow what's heappening to the MC + _xmouse
}
Hope it helps
Cheers
MKit :o)
-
I Like To Flash in Public ;)
thanks mkit!
u see when u sed
maxRight= 688; // MC maximum _x
what u mean by the movie clip maximum? meaning how long the actual movie clip is in pixels? or what.where is the measurement starting and ending?
Thanks
Blue Dragon
-
it is about the "registration point", you can see a cross in the middle, usually, of the MC when you high that MC, right? the _x and _y of that MC is the _x and _y of that cross
so Max MC _x / min MC_x is actually the position of that registration point
MKit
-
I Like To Flash in Public ;)
Thanks Mkit! your was great help! I got it to work exactly how i want!
Cheers!
Blue Dragon
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|