7 Replies Latest reply on Jun 17, 2010 10:55 PM by kglad

    [AS2] Send MovieClip colour value to dynamic text box

    TP Artroom

      Hi,

       

      I've been struggling to figure this bit out and it's driving me crazy.

       

      What happens in my flash file is I click on a colour swatch and that colour is then stored until I click on the part of the shirt I want to change colour. Once that part of the jersey has changed colour I want to be able to send the colour from just that section to a dynamic text field (to be emailed later as a reference). As an example, I click on "btn_orange" and then click on the Movie Clip "block1". "block1" changes to orange. As it changes I want to send "block1"'s colour to a text box called "hexcode1". If "block1" colour changes, then so will the text box "hexcode1". "block2" will be linked to "hexcode2" etc.

       

      Hopefully this explains it better. I would really appreciate any help as this is the major thing holding me back from completing this.

       

      Thanks for checking this out.

       

      Frame Script:


      var storedColor:String;
      color_txt.html = true;
      color_txt.autoSize = true;
      color_txt.htmlText = "Choose a color swatch";
      function setSwatchColor(colorNum:String):Void {
          storedColor = colorNum;
          var swatch:Color = new Color(swatch_mc);
          swatch.setRGB(parseInt(colorNum));
          color_txt.htmlText = colorNum;
      }
      function changeColor():Void {
          var col:Color = new Color(this);
          col.setRGB(parseInt(storedColor));
      }
      btn_maroon.onPress = function() {
          setSwatchColor("0x660033");
      };
      btn_red.onPress = function() {
          setSwatchColor("0xFF0000");
      };
      btn_orange.onPress = function() {
          setSwatchColor("0xFF6600");
      };
      block1.onPress = changeColor;
      block2.onPress = changeColor;

       

      IMAGE OF FLASH IN OPERATION

      Messy while I'm debugging.

       

      http://i50.tinypic.com/ir23km.jpg

        • 1. Re: [AS2] Send MovieClip colour value to dynamic text box
          kglad Adobe Community Professional & MVP
          use:

          var tl:MovieClip=this;

          var storedColor:String;
          color_txt.html = true;
          color_txt.autoSize = true;
          color_txt.htmlText = "Choose a color swatch";
          function setSwatchColor(colorNum:String):Void {
              storedColor = colorNum;
              var swatch:Color = new Color(swatch_mc);
              swatch.setRGB(parseInt(colorNum));
              color_txt.htmlText = colorNum;
          }
          function changeColor():Void {
              var col:Color = new Color(this);
              col.setRGB(parseInt(storedColor));

          tl["hexcode"+this._name.substring(4)].text=storedColor;
          }
          btn_maroon.onPress = function() {
              setSwatchColor("0x660033");
          };
          btn_red.onPress = function() {
              setSwatchColor("0xFF0000");
          };
          btn_orange.onPress = function() {
              setSwatchColor("0xFF6600");
          };
          block1.onPress = changeColor;
          block2.onPress = changeColor;



          • 2. Re: [AS2] Send MovieClip colour value to dynamic text box
            TP Artroom Level 1

            KGLAD:

             

            I tried your code, but couldn't get any joy from it. I've uploaded the source so you or anyone else can have a look and see why it may be occuring. Please be aware I still have cleaning to do on this and I've left the Email Movie Clip box up so hexcode & hexcode1 can be viewed. Thankyou for looking and hopefully there's a solution. Here's the source.

             

            http://www.tripleplay.com.au/tmp/flash.fla

             

            The code is on the layer "Action Script Layer" and the start frame for 1st design script is Frame 13. hexcode & hexcode1 are inside the email_box MovieClip up the top. block1 & block2 are apart of the design. "hexcode" instance name is hex_num1 and "hexcode1" instance name is hex_num2 so I'm looking at sending block1 colour to hex_num1 instance and block2 colour to hex_num2 instance.

             

            Thanks for looking.

            • 3. Re: [AS2] Send MovieClip colour value to dynamic text box
              kglad Adobe Community Professional & MVP

              what's the following trace() show:

               


              var tl:MovieClip=this;

              var storedColor:String;
              color_txt.html = true;
              color_txt.autoSize = true;
              color_txt.htmlText = "Choose a color swatch";
              function setSwatchColor(colorNum:String):Void {
                  storedColor = colorNum;
                  var swatch:Color = new Color(swatch_mc);
                  swatch.setRGB(parseInt(colorNum));
                  color_txt.htmlText = colorNum;

              trace(color_txt+" "+colorNum);

              }
              function changeColor():Void {
                  var col:Color = new Color(this);
                  col.setRGB(parseInt(storedColor));

              tl["hexcode"+this._name.substring(4)].text=storedColor;
              }
              btn_maroon.onPress = function() {
                  setSwatchColor("0x660033");
              };
              btn_red.onPress = function() {
                  setSwatchColor("0xFF0000");
              };
              btn_orange.onPress = function() {
                  setSwatchColor("0xFF6600");
              };
              block1.onPress = changeColor;
              block2.onPress = changeColor;



              • 4. Re: [AS2] Send MovieClip colour value to dynamic text box
                TP Artroom Level 1

                This is the output of the trace.

                 

                _level0.color_txt 0x660033

                • 5. Re: [AS2] Send MovieClip colour value to dynamic text box
                  kglad Adobe Community Professional & MVP

                  oops, wrong textfield.  (and that string method needs an adjustment).  use:

                   


                   


                  var tl:MovieClip=this;

                  var storedColor:String;
                  color_txt.html = true;
                  color_txt.autoSize = true;
                  color_txt.htmlText = "Choose a color swatch";
                  function setSwatchColor(colorNum:String):Void {
                      storedColor = colorNum;
                      var swatch:Color = new Color(swatch_mc);
                      swatch.setRGB(parseInt(colorNum));
                      color_txt.htmlText = colorNum;

                  }
                  function changeColor():Void {
                      var col:Color = new Color(this);
                      col.setRGB(parseInt(storedColor));

                  tl["hexcode"+this._name.substring(5)].text=storedColor;

                  trace("hexcode"+this._name.substring(5)+" "+tl["hexcode"+this._name.substring(5)]);

                  }
                  btn_maroon.onPress = function() {
                      setSwatchColor("0x660033");
                  };
                  btn_red.onPress = function() {
                      setSwatchColor("0xFF0000");
                  };
                  btn_orange.onPress = function() {
                      setSwatchColor("0xFF6600");
                  };
                  block1.onPress = changeColor;
                  block2.onPress = changeColor;



                  • 6. Re: [AS2] Send MovieClip colour value to dynamic text box
                    TP Artroom Level 1

                    Thankyou very much. After a little bit of tinkering I found my problem was that the dynamic text fields were inside a movie clip and that was causing some problems. Appreciate you help very much. Thankyou again.