flash actionscript:
I am attempting to make a more interesting background for a page that involves several objects moving slightly, depending on the 'x' coordinate of the mouse. I am trying to limit the movement to 100 pixels at the inverse of the mouse's 'x' coordinate. For clarity, I'll stick to just one object (object_mc) At the moment, I've been tossing around this basic code, which is hardly representative of what I'm trying to do, however I've never done anything regarding this movement. mouseInterval = setInterval (x_inverse, 10); function x_inverse () { object_mc._x = Math.round( [i]/// I've been plugging away and am starting to believe I need to use some sort of limiting function regarding _root._xmouse /// [/i] ); } The idea is that when the mouse is at x=0, object_mc is at x=100 and vice versa. These coordinates would also need to be flexible in that when the mouse is from x=1-500, 'object_mc' is from x=500-400. So, while the range for the '_root._xmouse' is the entire canvas, the range for the 'object_mc' would be limited to a defined area (such as 400-500). Any help would be appreciated, and I'd be more than willing to follow a tutorial on my own if pointed in the right direction. Thanks !
the function below will return your movieclip's _x property given the movieclip's range and mouse's range: function rangeF(mcX1, mcX2, mouseX1, mouseX2) { // mcX1 corresponds to mouseX1 etc var a = (mcX1-mcX2)/(mouseX1-mouseX2); var b = mcX1-a*mouseX1; return a*_root._xmouse+b; }
Don't see what you're looking for? Try a search.
|