4 Replies Latest reply on Dec 22, 2011 6:59 PM by mellisasa

    Newbie - need help understanding the code? :D

    mellisasa

      so, i found a code, that have the effect that I want.. which is that the arrow will move smoothly up and down.

      but, i am a bit confused because currently its in movie clip and its moving just fine, but when i change it to button,

      its not working?

      the reason i want it to be button is because i want it to show different content, when i click different button.

       

      here is the code,

       

      thanks for the help!

      --------------------------------------------------------------

      MovieClip.prototype.easeY = function(y) {

                this.onEnterFrame = function() {

                          this._y = y-(y-this._y)/1.2;

                          if (this._y>y-1 && this._y<y+1) {

                                    delete this.onEnterFrame;

                          }

                };

      };

      MovieClip.prototype.controlArrow = function() {

                this.onRelease = function() {

                          arrowMC.easeY(this._y);

                };

      };

      link1.controlArrow();

      link2.controlArrow();

      link3.controlArrow();

      link4.controlArrow();

      link5.controlArrow();

      link6.controlArrow();

      link7.controlArrow();

      link8.controlArrow();

      link9.controlArrow();

      link10.controlArrow();

      link11.controlArrow();

      link12.controlArrow();

      --------------------------------------------------------------

        • 1. Re: Newbie - need help understanding the code? :D
          Ned Murphy Adobe Community Professional & MVP

          You can use MovieClips instead of buttons.  Just assign linking code to them in the onRelease portion of your code that you show.  Each MovieClip should have some property assigned to it for the link that it involves and your onRelease function should process that property.

           

          MovieClip.prototype.controlArrow = function() {

                    this.onRelease = function() {

                              arrowMC.easeY(this._y);

           

                              // your linking code goes here

                    };

          };

           

          I believe the problem with using Buttons is because Buttons are not dynamic objects like MovieClips are.  You can dynamically assign new properties and methods to a MovieClip, but the same does not apply to Buttons.

          1 person found this helpful
          • 2. Re: Newbie - need help understanding the code? :D
            mellisasa Level 1

            Thanks!!! then. because now,, its movie clip, then, if for example, the link1.controlArrow part << i want this part to go a particular scene when i release mouse, is that possible?

            • 3. Re: Newbie - need help understanding the code? :D
              Ned Murphy Adobe Community Professional & MVP

              If you use a gotoAndPlay(scene, frame); where I show "// your linking code goes here" and substitute the values for scene, frame then it could work. 

               

              One poential problem is that using scenes in Flash is often unpredictably problematic when you try to introduce navigation with them.  I never use scenes in my own work due to that.  I will instead either create separate sections as movieclips and/or spread them along one timeline.

              • 4. Re: Newbie - need help understanding the code? :D
                mellisasa Level 1

                I tried it and it works! but now, its only like one click and it will only play once. if for example, there is now link1 and link2 and so on, and i want to have different content coming up everytime i click on the link 1 or link 2? is it possible?

                for example now : on link 1, when i released it, character A  will come up, but when link 2 is clicked, the A will fade out, and character 'B' will appear instead.. is it possible?

                 

                thanks!