13 Replies Latest reply on Jan 15, 2010 2:02 PM by kglad

    Having issues applying classes to my textfield.

    baianomauricioct

      Hi all, good morning. I can't express good enough how this forum has been so great to me. I am learning SO MUCH the actionscript. Anyways, my problem now refers to the css. I have a quotes.css already been loaded into the flash, how can I apply a class to a textfield, the code is below but it's now working properly.

       

      Anyone might be kind enough to help?

       

      Thanks.

       

       

      var tl:MovieClip = this;

      var colnum:Number = 2;

      var xSpace:Number = 200;

      var ySpace:Number = eval("column"+i);

      for (var i = 1; i<=30; i++) {

          tl.createTextField("column"+i,tl.getNextHighestDepth(),xSpace*((i-1)/colnum),ySpace,200,3 0);

          tl["column"+i].html = true;

      }

      tl.createTextField("resultsField",tl.getNextHighestDepth(),xSpace,ySpace*Math.floor(i+coln um/colnum),200,30);

      resultsField.html = true;

      resultsField.html = true;

      this.createTextField("moeda",this.getNextHighestDepth(),325,80,200,30);

      var my_xml = new XML();

      var stylish = new TextField.StyleSheet();

      stylish.load("quotes.css");

      stylish.onLoad = function(success:Boolean) {

          if (success) {

                     trace("cssLoaded!");

              tl["column"+i].styleSheet = stylish;

              my_xml.onLoad = function(yeah:Boolean) {

                  if (yeah) {

                      var a:Array = [];

                      for (var i = 1; i<=30; i++) {

                          RootNode = my_xml.firstChild;

                          eval("column"+i).htmlText = "<p class='regular'>"+RootNode.childNodes[i].firstChild+"</p>";

                          a.push(Number(stripF(tl["column"+i].text)));

                          moeda.htmlText = stripF(RootNode.childNodes[0].firstChild.nodeValue);

                          //trace(column10._y);

                          //trace(column20._x);

                          trace(resultsField.text);

                          trace(stripF(RootNode.childNodes[0].firstChild.nodeValue));

                      }

                      resultsField.htmlText = minF(a);

                  } else {

                      trace("buahCol!");

                  }

              };

              my_xml.ignoreWhite = true;

              my_xml.load("quotes.xml");

          }

      };

      function minF(a:Array):Number {

          var min:Number = a[0];

          for (var i:Number = 1; i>a.length; i++) {

              if (a[i]<min) {

                  min = a[i];

              } else {

                  trace("buahMin!");

              }

          }

          return min;

       

      function stripF(s:String):String {

          return s.split(" ").join("").split("\n").join("").split("\r").join("");

      }

        • 1. Re: Having issues applying classes to my textfield.
          kglad Adobe Community Professional & MVP

          use:

          var tl:MovieClip = this;
          var colnum:Number = 2;
          var xSpace:Number = 200;
          var ySpace:Number = eval("column"+i);
          for (var i = 1; i<=30; i++) {
              tl.createTextField("column"+i,tl.getNextHighestDepth(),xSpace*((i-1)/colnum),yS pace,200,30);
              tl["column"+i].html = true;
          }
          tl.createTextField("resultsField",tl.getNextHighestDepth(),xSpace,ySpace*Math.fl oor(i+colnum/colnum),200,30);
          resultsField.html = true;
          resultsField.html = true;
          this.createTextField("moeda",this.getNextHighestDepth(),325,80,200,30);
          var my_xml = new XML();
          var stylish = new TextField.StyleSheet();
          stylish.load("quotes.css");
          stylish.onLoad = function(success:Boolean) {
              if (success) {
                         trace("cssLoaded!");
                  tl["column"+i].styleSheet = stylish;
                 
                  my_xml.load("quotes.xml");
              }
          };

          my_xml.onLoad = function(yeah:Boolean) {
                      if (yeah) {
                          var a:Array = [];
                          for (var i = 1; i<=30; i++) {
                              RootNode = my_xml.firstChild;
                              eval("column"+i).htmlText = "<p class='regular'>"+stripF(RootNode.childNodes[i].firstChild)+"</p>";
                              a.push(Number(stripF(tl["column"+i].text)));
                              moeda.htmlText = stripF(RootNode.childNodes[0].firstChild.nodeValue);
                              //trace(column10._y);
                              //trace(column20._x);
                              trace(resultsField.text);
                              trace(stripF(RootNode.childNodes[0].firstChild.nodeValue));
                          }
                          resultsField.htmlText = minF(a);
                      } else {
                          trace("buahCol!");
                      }
                  };
          my_xml.ignoreWhite = true;

          function minF(a:Array):Number {
              var min:Number = a[0];
              for (var i:Number = 1; i>a.length; i++) {
                  if (a[i]<min) {
                      min = a[i];
                  } else {
                      trace("buahMin!");
                  }
              }
              return min;

          function stripF(s:String):String {
              return s.split(" ").join("").split("\n").join("").split("\r").join("");
          }
          • 2. Re: Having issues applying classes to my textfield.
            baianomauricioct Level 1

            Sorry, but it didn't work.

            • 3. Re: Having issues applying classes to my textfield.
              baianomauricioct Level 1

              this is what I have in my css file:

               

              .regular {
                font-family: Arial,Helvetica,sans-serif;
                font-size: 24px;
                color: #FF0000;
              }

              • 4. Re: Having issues applying classes to my textfield.
                baianomauricioct Level 1

                Funny, because it won't work even if I input this

                 

                            eval("column"+i).htmlText = "<p style='font-size:30px'>"+RootNode.childNodes[i].firstChild+"</p>";

                • 5. Re: Having issues applying classes to my textfield.
                  kglad Adobe Community Professional & MVP

                  are your textfields html enabled?

                  • 6. Re: Having issues applying classes to my textfield.
                    baianomauricioct Level 1

                    yes, they are:

                     

                        tl["column"+i].html = true;

                    • 7. Re: Having issues applying classes to my textfield.
                      kglad Adobe Community Professional & MVP

                      try it without specifying a font-family.

                      • 8. Re: Having issues applying classes to my textfield.
                        baianomauricioct Level 1

                        no dice!

                         

                        it didn't work out.

                        • 9. Re: Having issues applying classes to my textfield.
                          kglad Adobe Community Professional & MVP

                          zip your css, xml and fla and attach to this forum.

                          • 11. Re: Having issues applying classes to my textfield.
                            kglad Adobe Community Professional & MVP

                            you're not assigning the styleSheet property to your textfields.  use:

                             

                            kglad wrote:

                             

                            use:

                            var tl:MovieClip = this;
                            var colnum:Number = 2;
                            var xSpace:Number = 200;
                            var ySpace:Number = eval("column"+i);
                            for (var i = 1; i<=30; i++) {
                                tl.createTextField("column"+i,tl.getNextHighestDepth(),xSpace*((i-1)/colnum),yS pace,200,30);
                                tl["column"+i].html = true;
                            }
                            tl.createTextField("resultsField",tl.getNextHighestDepth(),xSpace,ySpace*Math.fl oor(i+colnum/colnum),200,30);
                            resultsField.html = true;
                            resultsField.html = true;
                            this.createTextField("moeda",this.getNextHighestDepth(),325,80,200,30);
                            var my_xml = new XML();
                            var stylish = new TextField.StyleSheet();
                            stylish.load("quotes.css");
                            stylish.onLoad = function(success:Boolean) {
                                if (success) {
                                           trace("cssLoaded!");
                            for (var i = 1; i<=30; i++) {
                                    tl["column"+i].styleSheet = stylish;
                            }

                                   
                                    my_xml.load("quotes.xml");
                                }
                            };

                            my_xml.onLoad = function(yeah:Boolean) {
                                        if (yeah) {
                                            var a:Array = [];
                                            for (var i = 1; i<=30; i++) {
                                                RootNode = my_xml.firstChild;
                                                eval("column"+i).htmlText = "<p class='regular'>"+stripF(RootNode.childNodes[i].firstChild.nodeValue)+"</p>";
                                                a.push(Number(stripF(tl["column"+i].text)));
                                                moeda.htmlText = stripF(RootNode.childNodes[0].firstChild.nodeValue);
                                                //trace(column10._y);
                                                //trace(column20._x);
                                                trace(resultsField.text);
                                                trace(stripF(RootNode.childNodes[0].firstChild.nodeValue));
                                            }
                                            resultsField.htmlText = minF(a);
                                        } else {
                                            trace("buahCol!");
                                        }
                                    };
                            my_xml.ignoreWhite = true;

                            function minF(a:Array):Number {
                                var min:Number = a[0];
                                for (var i:Number = 1; i>a.length; i++) {
                                    if (a[i]<min) {
                                        min = a[i];
                                    } else {
                                        trace("buahMin!");
                                    }
                                }
                                return min;

                            function stripF(s:String):String {
                                return s.split(" ").join("").split("\n").join("").split("\r").join("");
                            }