2 Replies Latest reply on Jun 28, 2007 12:42 AM by Newsgroup_User

    Modify an _alpha value but gradually

    Level 7
      Hello,

      I would like by clicking on a clip which acts as button, that another clip
      named clip2 can see his value _alpha changing but gradually and slowly as
      long as my mouse remains on the reactive clip.

      I know how to do in one time like this :

      one(rollover) {
      _root.clip2. _alpha=5;
      .....

      But how to do for example a change from _alpha=100 to _alpha=5 and slowly
      and in ActionScript, without having to carry out an interpolation on a
      timeline.

      I tested with a loop but that does not give anything.

      Thank you! :)

      An sorry for my bad english !!
      Pierre


        • 1. Re: Modify an _alpha value but gradually
          ricky grows
          this is off the top of my head so it may not work right away, but should get you on the right track.

          put a button on the stage and give it an instance name of "my_btn".

          put the movieclip you want to change the _alpha of on the stage and give it an instance name of "my_mc"

          now on the first frame of your timeline, put this actionscript code:

          // --
          my_mc.alpha_speed = 1;
          my_btn.onRollOver = function ()
          {
          _parent.my_mc.onEnterFrame = function ()
          {
          this._alpha -= this.alpha_speed;
          }
          }

          my_btn.onRollOut = function ()
          {
          _parent.my_mc.onEnterFrame = null;
          }
          //--
          • 2. Re: Modify an _alpha value but gradually
            Level 7
            Thanks ! :-)
            In fact i've found the solution like this :

            _root.clip2.onEnterFrame = function() {
            if (_root.clip2._alpha>35) {
            _root.clip2._alpha -= 2;
            } else {
            _root.clip2._alpha = 35;
            }
            };


            It works well ! :-)
            So I've another question but i write it in another subject !


            "ricky grows" <webforumsuser@macromedia.com> a écrit dans le message de
            news: f5voj3$me6$1@forums.macromedia.com...
            > this is off the top of my head so it may not work right away, but should
            > get
            > you on the right track.
            >
            > put a button on the stage and give it an instance name of "my_btn".
            >
            > put the movieclip you want to change the _alpha of on the stage and give
            > it an
            > instance name of "my_mc"
            >
            > now on the first frame of your timeline, put this actionscript code:
            >
            > // --
            > my_mc.alpha_speed = 1;
            > my_btn.onRollOver = function ()
            > {
            > _parent.my_mc.onEnterFrame = function ()
            > {
            > this._alpha -= this.alpha_speed;
            > }
            > }
            >
            > my_btn.onRollOut = function ()
            > {
            > _parent.my_mc.onEnterFrame = null;
            > }
            > //--
            >