1 Reply Latest reply on Jan 21, 2010 10:06 AM by baianomauricioct

    Function to change alpha of a movie clip

    baianomauricioct

      Hi all, I am having this bit of code not working for me. I want to have a function 'thisAplha'to analyze a mc's alpha stage, and depending on it either appear or disappear it. Basically I am trying to disappear/appear on screen the inv0 mc when you click it.

       

      Actionscripit:

       

      stop(); var mbx = _root.page.MsgBox; var mouseXspace = this._xmouse+20; var mouseYspace = this._ymouse+20; var css = new TextField.StyleSheet(); cssurl = "includes/default.css"; css.load(cssurl); css.onLoad = function(success) {      if (success) {           for (i=0; i<=6; i++) {                this.eval("txt"+i).html = true;                this.eval("txt"+i).multiline = true;                this.eval("txt"+i).wordWrap = true;                this.eval("txt"+i).styleSheet = css;                eval("txt"+i).htmlText = eval("_root.page.data.label"+i);           }      } }; inv0.onRelease = function() {      thisAlpha(inv0);      //inv0._alpha = 100;      mbx.lockCenter(false);      mbx.lockWidth("300");      mbx.setAutoSize();      mbx._x = mouseXspace;      mbx._y = mouseYspace;      mbx.setMsgBoxStyle(_root.page.lessonTwo);      mbx.popup(_root.page.data.text1); }; inv1.onRelease = function() {      inv1._alpha = 100;      mbx.lockCenter(false);      mbx.lockWidth("300");      mbx.setAutoSize();      mbx._x = mouseXspace;      mbx._y = mouseYspace;      mbx.setMsgBoxStyle(_root.page.lessonTwo);      mbx.popup(_root.page.data.text2); }; inv2.onRelease = function() {      inv2._alpha = 100;      mbx.lockCenter(false);      mbx.lockWidth("300");      mbx.setAutoSize();      mbx._x = mouseXspace;      mbx._y = mouseYspace;      mbx.setMsgBoxStyle(_root.page.lessonTwo);      mbx.popup(_root.page.data.text3); }; function thisAlpha(yeah:MovieClip) {      if (this[yeah]._alpha <= 50) {           this[yeah]._alpha = 100;           trace;      }      if (this[yeah]._alpha >= 51) {           this[yeah]._alpha = 0;      } else {           this[yeah]._alpha = 40;      } }

       

      Thank you all.

       

      Mauricio

        • 1. Re: Function to change alpha of a movie clip
          baianomauricioct Level 1

          code:

           

          stop();
          var mbx = _root.page.MsgBox;
          var mouseXspace = this._xmouse+20;
          var mouseYspace = this._ymouse+20;
          var css = new TextField.StyleSheet();
          cssurl = "includes/default.css";
          css.load(cssurl);
          css.onLoad = function(success) {
              if (success) {
                  for (i=0; i<=6; i++) {
                      this.eval("txt"+i).html = true;
                      this.eval("txt"+i).multiline = true;
                      this.eval("txt"+i).wordWrap = true;
                      this.eval("txt"+i).styleSheet = css;
                      eval("txt"+i).htmlText = eval("_root.page.data.label"+i);
                  }
              }
          };
          inv0.onRelease = function() {
              thisAlpha(inv0);
              //inv0._alpha = 100;
              mbx.lockCenter(false);
              mbx.lockWidth("300");
              mbx.setAutoSize();
              mbx._x = mouseXspace;
              mbx._y = mouseYspace;
              mbx.setMsgBoxStyle(_root.page.lessonTwo);
              mbx.popup(_root.page.data.text1);
          };
          inv1.onRelease = function() {
              inv1._alpha = 100;
              mbx.lockCenter(false);
              mbx.lockWidth("300");
              mbx.setAutoSize();
              mbx._x = mouseXspace;
              mbx._y = mouseYspace;
              mbx.setMsgBoxStyle(_root.page.lessonTwo);
              mbx.popup(_root.page.data.text2);
          };
          inv2.onRelease = function() {
              inv2._alpha = 100;
              mbx.lockCenter(false);
              mbx.lockWidth("300");
              mbx.setAutoSize();
              mbx._x = mouseXspace;
              mbx._y = mouseYspace;
              mbx.setMsgBoxStyle(_root.page.lessonTwo);
              mbx.popup(_root.page.data.text3);
          };
          function thisAlpha(yeah:MovieClip) {
              if (this[yeah]._alpha <= 50) {
                  this[yeah]._alpha = 100;
                  trace;
              }
              if (this[yeah]._alpha >= 51) {
                  this[yeah]._alpha = 0;
              } else {
                  this[yeah]._alpha = 40;
              }
          }