1 Reply Latest reply on Jun 20, 2008 2:04 PM by JohnWalsh2011

    concatentation inside an if statement

    gbowhall
      Hello all:

      I am having what seems to be the most basic trouble with concatenating a variable inside an "if" conditional. Sometimes I can just stare at this stuff and know I am just overlooking something completely obvious. Okay here we go.

      This if statement does what I need:
      if ((_level0.panoramic_mc._x -_level0.speed) <= -372) {

      when I try to replace the number "-372" with a variable, it doesn't work anymore.
      if ((_level0.panoramic_mc._x -_level0.speed) <= _level0.movieLastPosition) {

      I ran a trace to check "_level0.movieLastPosition" and it does spit out -372.

      Am I missing something obvious? I tried putting () around the variable as well as[].

      --
      EDIT: I realize the answer may lie outside the info I gave above, so I am including more of the code:

      ////////////////* ENTER NUMBER OF SLIDES IN PANORAMA ///////////////////
      _level0.numOfSlides = 2;
      _level0.startPosition = 178;
      _level0.movieLenth = 550;
      _level0.moviePosition1 = _level0.startPosition
      _level0.moviePosition2 = [178-(1*550)]

      _level0.movieLastPosition = eval("_level0.moviePosition" + _level0.numOfSlides)



      var xSlideID;
      xSlideID = setInterval( callxSlide, 50 );

      ////////////////* FUNCTION: ACTS ON MOUSE POSIITON ///////////////////
      function callxSlide() {

      ////////////////* SCROLLS TO END ///////////////////
      if ((_xmouse > 538) && (_xmouse < 903) && (_ymouse < 196)) {
      _level0.speed = (_xmouse - 538) / 10;

      if ((_level0.panoramic_mc._x -_level0.speed) <= _level0.movieLastPosition) {
      _level0.panoramic_mc._x = -372
      } else {
      _level0.panoramic_mc._x = _level0.panoramic_mc._x - _level0.speed;
      }


      }
      Thanks for your help!
      - Garrett

        • 1. Re: concatentation inside an if statement
          JohnWalsh2011
          When using conditional logic is AS I always format multiple conditions with multiple Parentheses. It usually effects whether the conditions fails or not!

          if (
          (_level0.panoramic_mc._x -_level0.speed) <=
          (_level0.movieLastPosition)
          )

          And they usually work when there formatted like that. Also you left out colons in three of the lines.