Skip to main content
Known Participant
September 6, 2007
Question

converting values for scaling

  • September 6, 2007
  • 3 replies
  • 408 views
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
This topic has been closed for replies.

3 replies

kglad
Community Expert
Community Expert
September 6, 2007
that's not actionscript. that's an equation to show what you're really doing. comment that out of your actionscript or delete it.
Known Participant
September 6, 2007
okay, I see. Dont understand the equation, but deleting works so thats all I need to know \\thanks

adam
kglad
Community Expert
Community Expert
September 6, 2007
you're welcome.
kglad
Community Expert
Community Expert
September 6, 2007
you're welcome.
kglad
Community Expert
Community Expert
September 6, 2007
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:

Known Participant
September 6, 2007
quote:

Originally posted by: kglad
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.

Many thanks for your quick reply
adam