algebra - Me = flash headache
- Started
- Last post
- 10 Responses
- Cenitgrade
Anyone know a little formula that does this.
I'm tracking the _xmouse and moving an object relative to that. How do I set a max and min value.So if the user goes past a certain _xmouse value the returned value will alway be the same.
Aggghhh
Thanks!
- plash0
LocH, LocV
but that may have been phased out.
been awhile since i've played with AS
- Cenitgrade0
what I have so far. It's not working yet though:
a = Stage.width/2;
b = _xmouse;
c = (b-a);
if (b>1280){
b = 1280
};
if (b>0){
b = 0
};
xMoviePos = a-c;
- TINKLDN0
if (b<0){
- lukus_W0
do a dummy run without using the computer...
lets say that b = 450
.. if this is the case it will pass the first if comparison and be assigned 1280.. but then it will also pass the next comparison and be assigned with 0 (which it will stick with)
- kumori040
//Don't allow object past 50, or 300.
var minX:Number = 50;
var maxX:Number = 300;myObject._x = Math.max(minX, Math.min(_xmouse, maxX));
So, the _x value of myObject will stop at minX, or become higher unless maxX is reached. I haven't tested, but that should work.
- powertoni0
function chaseSomething(chaser,scopeObjec... {
var easing:Number = 10;
var tx:Number = 0;
var minDistance:Number = 0;
var maxDistance:Number = 0;
var limit:Number = 1280;chaser.onEnterFrame = function(){
if(scopeObject._xmouse >limit){
tx = something;//limit?
}else{
tx+= (scopeObject._xmouse - this.x)/easing;
}
this.x = tx;
}
}chaseSomething(targetMx,this);
- Cenitgrade0
you people are so brainy! Thanks. I think Kumori's answer is working best so bar.
Cheers,
Ian- so far ... sober ... so to the bar. Hmm my subconscious needs a beer.Cenitgrade
- juhls0
You mean Me + Algebra = flash headache
- cuke4260
var p = mouseX;
p = Math.max(0,p)
p = Math.min(100, p)this will give you a range of 0-100
shorthand =
p = Math.min(Math.max(0,mouseX), 100);