How would I get this happening as it is but based on the center of the rectangle, rather than on the left side (xpos = 0), when you test this in the application?
Hope this is somewhat clear!
Maybe... But it would sort of be containing the people in that window, on either side...
That said there's somewhat awkward in your other file...
Look at the position of the mouse on the left, when the ball is just leaning on the right border, then the mouse position on the right, when the ball is leaning on the left border... Not the same. Nor does it work the same at all, when screening the .swf?
arg..just worked on it some more and made even more of a mess of it!! I'm off to bed, good luck with it, oldnewbie
As far as the jumping on that link, it's a hitTest on a mc over the scroll thing, if you hit it "off center" if reacts according to the script. Not perfect, but you know my experience with flash, surprised I pulled that one off actually
Cool! Can even change those numbers for different offsets...
Now, why doesn't this work properly when tested in the application?
And one last question... What if I wanted it to move according to the mouse's position but not on the whole stage's width... say 20 pixels from either the left or the right border?
Basically the trick is getting whatever mouse range you want into ratio (which is a number that must go from 0 - 1.
So if the desired mouse range is 20 - 50, you would use something like:
code:
xm = _root._xmouse;
// are we in the correct range?
if (xm >= 20 && xm <= 50) {
// change scale from 20-50 to 0-1
ratio = (xm - 20) / (50 - 20);
// optional step - reverse mouse
ratio = 1-ratio;
// change scale from 0-1 to 50-500
endX = (500-50)*ratio + 50;
}
The reverse step causes the mouse to have the opposite effect in that range (e.g. mouse on left pushes object to right).
Also notice that equation to get the ratio is closely related to the equation to get the endX (they are both scaling operations, which basically involve multiplication or division by a scaling factor).