2 Replies Latest reply on Feb 5, 2007 12:41 PM by Newsgroup_User

    inverting number values in action script

    fotostrations Level 1
      Hello fellow flashers,

      I have a slide bar type button that delivers values of -50 to +50 based on an _y position.
      I have two line animations that are controlled by the same switch. However, what I want to happen is to have the animations to have an opposite reaction to the slider bar.

      The first line animation changes it's _y position based on the slider bar _y position, this works great, no problem.
      The second line animation has the same properties and is connected in the same way, what I want to happen is for this animation to invert the input values. (i.e. when line one goes up on the _y position, the second goes down on the _y position.
      Here's the line of code in question:

      /*this.onEnterFrame = function() {
      rspot = _parent.slider_mc.vertFader._y/2;
      }*/
      the value of the vertFader _y is the -50 to +50
      Anyone have any insight, I would be truly greatful for any help here.

      Thanks,
      Robert
        • 1. Re: inverting number values in action script
          Level 7
          Hi,

          unless I overlook something, multiplying by -1 shoud do it, right?
          or:

          rspot = -(_parent.slider_mc.vertFader._y) / 2

          Manno

          fotostrations wrote:
          > Hello fellow flashers,
          >
          > I have a slide bar type button that delivers values of -50 to +50 based on an
          > _y position.
          > I have two line animations that are controlled by the same switch. However,
          > what I want to happen is to have the animations to have an opposite reaction to
          > the slider bar.
          >
          > The first line animation changes it's _y position based on the slider bar _y
          > position, this works great, no problem.
          > The second line animation has the same properties and is connected in the same
          > way, what I want to happen is for this animation to invert the input values.
          > (i.e. when line one goes up on the _y position, the second goes down on the _y
          > position.
          > Here's the line of code in question:
          >
          > /*this.onEnterFrame = function() {
          > rspot = _parent.slider_mc.vertFader._y/2;
          > }*/
          > the value of the vertFader _y is the -50 to +50
          > Anyone have any insight, I would be truly greatful for any help here.
          >
          > Thanks,
          > Robert
          >

          --
          ----------
          Manno Bult
          http://www.aloft.nl
          manno@xs4all.nl
          • 2. Re: inverting number values in action script
            fotostrations Level 1
            Never mind.... thought it through, came up with

            rspot = (_parent.slider_mc.vertFader._y*-1)/2;

            thanks anyways!

            Robert