4 Replies Latest reply on Sep 9, 2010 9:26 PM by HellEmbracer

    Codeing noob (me)

    HellEmbracer Level 1

      Hello im having a prob like im trying to be a animater i have sprites made em into gifs then i made them all be activated by left or right key arrows but

      i dont know how to add a diffrent code so that when he stops he wont be doing the animation where he stops and looks right cause u see i want him to move left then when i let go of the key i want him to be keep looking left but not moving heres my code please tell how to add another line or fix it so i can add still2 where hes looking left while standing there

       

      var rollSpeed = Number=10;

       

      ichigo_mc.onEnterFrame = function() {
          if (Key.isDown(Key.RIGHT)) {
              this._x += rollSpeed;
              this.gotoAndStop("right");
          } else if (Key.isDown(Key.LEFT)) {
              this._x -= rollSpeed;
              this.gotoAndStop("left");
          } else {
              this.gotoAndStop("still");
          }
      };

       

                Please help if you know code im dumbfounded, cause im a coding noob got this code from youtube

        • 1. Re: Codeing noob (me)
          Ned Murphy Adobe Community Professional & MVP

          It is really hard to understand what you are trying to explain, so you may have to take your time and try to explain it again.  But I do get some ideas as to what you might want so here's a suggestion.  Try changing it as follows and see if it is more like what you want...

           

          var rollSpeed = Number=10;

           

          this.gotoAndStop("still");

           

          ichigo_mc.onEnterFrame = function() {
              if (Key.isDown(Key.RIGHT)) {
                  this._x += rollSpeed;
                  this.gotoAndStop("right");
              } else if (Key.isDown(Key.LEFT)) {
                  this._x -= rollSpeed;
                  this.gotoAndStop("left");

              }
          };

           

          You will need to add a new condition (key command) if you want to return to the still position.  Try to think about what the code is making happen... that is how you learn how to solve these things yourself.

          1 person found this helpful
          • 2. Re: Codeing noob (me)
            HellEmbracer Level 1

            ok thanks, for the problem helping but sorry im a noob, so

            to add another line of code do i add it after the 'go to and stop left' thing

            like how should i word the code (sorry for being an idiot) do i then put

            like gotoAndStop('still') but if i do that how would it know only to stop

            after i let go of the right key, cause 'still' is the char sitting there staring right

            and i want the char to stare where he was heading. i have a animation where he stares left

            but i do not know how to stop him from using 'still'

            • 3. Re: Codeing noob (me)
              Ned Murphy Adobe Community Professional & MVP

              You are still not explaining things clearly.  Did you try using the code I showed instead of what you have?  The code I showed will not return to the still position after right or left movement.

              1 person found this helpful
              • 4. Re: Codeing noob (me)
                HellEmbracer Level 1

                yes i tried the code, i want the char to stop moving, with my animation i

                have aka still like if the char moves left i want him to stop but also be

                looking left my code could only have 1 position after stoping, which was

                still which pointed right, i wanted to know if after going right can i have

                like a code that says after he stops he starts (blah) which if he going

                right would be still which points right or still2 which points left,what im

                saying is i need a code that is inputed after movement thats say stop when i

                let go of certain key like if i press right i want him to move then i let go

                i want him to look right. if i press left i want him to move then i let go i

                then want him to left like he stopped and is looking in the direction he was

                going. - because i have animations for his standing like his hair just blows

                in the wind while standing there. im sorry but do u understand

                 

                                          sincerly jason lachmann