7 Replies Latest reply on Sep 6, 2007 1:55 PM by kglad

# converting values for scaling

Hi

I need to map one set of values to another to control the scaling of an MC.
I need the _y value of 482 to equal 15% _yscale, and the _y value to equal 100% _yscale.

The code I fudged so far goes:
this.scanner_mc.onEnterFrame = function(){
this._x = _root._xmouse;
updateAfterEvent();
}
this.beam_mc.onEnterFrame = function(){
this._x = _root._xmouse;
this._yscale = stretch;
stretch = laser_mc._y * -.41+215;
trace("STR="+stretch);
trace("MCY="+laser_mc._y);
updateAfterEvent();
}

this.laser_mc.startDrag(true, 80, 240, 660, 500);

I basically guessed at the values for 'stretch' but I know there has to be a smart trigonometry way of calculating it.

It is easier if I show you, so I posted an SWF/FLA so you can see what I am trying to acheive and the code I have used so far to get there.

http://dev.binaryinteractive.com/public/scanner.swf
http://dev.binaryinteractive.com/public/scanner.fla

many thanks
mm66
• ###### 1. Re: converting values for scaling
you don't have a value of _y that corresponds to 100%. but, in general, for two independent variable values (_y) and two dependent values (scaling), you can use algebra to find a linear equation that defines a function giving your dependent values:

• ###### 2. Re: converting values for scaling
quote:

you can use algebra to find a linear equation that defines a function giving your dependent values:

That is exactly what I was trying to say, thanks for putting it so succinctly for me. In AfterEfects there is an expression called Linear that does just this. Could not find any built in method equivalent to this in Flash.

will go check out your function and see how I can make it work for my project. i'll get back with questions if I have them.

• ###### 3. Re: converting values for scaling
you're welcome.
• ###### 4. Re: converting values for scaling

trying to plug this in to my script, I get this error:

Left side of assignment operator must be variable or property.
f(x) = a*x + b;

Can you explain further what this line does, and how it executes the scale conversion

thanks