6 Replies Latest reply on Oct 4, 2007 11:50 AM by SymTsb

    Apply font styles to text field

    Chrisatlemon
      Hi all,

      I have nothing but themost basic noob knowledge of Flash and actionscript, so I would really appreciate some help!

      I created a Flash with a text field that pareses and RSS feed. Just copied the AS from here:

      http://www.yourminis.com/developers/...s/as3/rss.aspx

      Fair enough, easy, copy&paste and it works.

      Now I want to style this text field: font colorm link color, header color, background color etc. With CSS/HTML this would take me 10 secs.

      I have literally spent 6 hours reading documentation, tutorials, trial and error. Nothing works. Is it THAT difficult to style text inside an element with AS???

      Any help would be much appreciated. Maybe an example I can paste into the code referenced above so I can see how this would work, as anything else I read just never did!

      Thanks for the help!

      Chris
        • 1. Re: Apply font styles to text field
          SymTsb Level 2
          What method are you trying to use? TextFormat and CSS all require that the text be added before the formatting is applied. Perhaps you are trying to add/change the text in the field after the formatting is applied which would make it appear as though the formatting isn't applying (when it reality it is being removed).
          • 2. Re: Apply font styles to text field
            Chrisatlemon Level 1
            Thanks for your answer :)

            I know little about Flash, but the procedure is the following:

            The Flash parses an RSS file and displays it in the textfield. So the text gets loaded dynamically, pulling whatever RSS you specified.

            Therefore I want to apply general styles to the textfield, so that whatever text gets pulled into it and displayed has a certain font and colour. Maybe even assign color for headers, links and paragraph.

            Now, no matter how it actually works, anything I read on loading CSS into the flash, using AS to style the text field, I couldn't get anything to work.

            I would be greatful if anyone had an example of a flash file which styles a text field so I could actually see how it's done in practice instead of spmnding hours reading through incomplete and cryptic documentation which only ever half addresses my issues :)

            Thanks again!

            Chris
            • 3. Re: Apply font styles to text field
              SymTsb Level 2
              Do you need this done is AS2 or AS3? The process is different for both. More than willing to supply an example but need to know the language it has to be coded in.
              • 4. Re: Apply font styles to text field
                Chrisatlemon Level 1
                Thanks very much, that's very kind of you!

                It's AS3. Sorry, I just realised the link above doesn't work:

                http://www.yourminis.com/developers/tutorials/as3/rss.aspx

                This is where it nees to go. This is AS3 and created the RSS parser inside the Flash. This is the basic version, code as follows

                ******************

                var widget; //Widget
                var rss;
                var textfield:TextField;

                addEventListener("widget-loaded",onWidgetLoaded);

                function onWidgetLoaded(evt:Event)
                {
                //your widget has started and is ready for display
                widget.initWidget(300,400,0xffffff);

                //add the textfield to the form
                textfield = new TextField();
                textfield.x = 5;
                textfield.y = 5;
                textfield.width = 280;
                textfield.height = 380;
                textfield.multiline = true;
                textfield.wordWrap = true;

                addChild(textfield);

                rss = widget.newRSS();
                rss.addEventListener(Event.COMPLETE,onRSSLoaded);
                rss.load(new URLRequest(" http://feeds.feedburner.com/yourminis"));
                }

                function onRSSLoaded(evt:Event)
                {
                var loader:URLLoader = URLLoader(evt.target);
                var rssxml:XML = XML(loader.data);

                var str = "";
                for each (var item:XML in rssxml..item)
                {
                str+="<b><a href='" + item.link + "' target='_blank'><u>" +
                item.title + "</u></a></b><br/>" +
                item.description + "<br/><br/>";
                }
                textfield.htmlText = str;
                }

                ********************

                I want all the text inside this textfield containing to be styled to my liking. I don't know enought about Flash, but with CSS I could style each element individually and/or apply global styles to the entire element.

                Thanks again for your help!

                Chris

                • 5. Re: Apply font styles to text field
                  Chrisatlemon Level 1
                  Another thing I may add, no offense intended, I don't know if there are any rules about this. But while on this project, which is a quick job with a few snippets I may just contract a Flash pro to do it for me. If you are interested in this sort of "quickie" then I'd be more than happy to pay you for anything you do for me.

                  If I broke forum rules or offended you by proposing this then please disregard, no offence intended whatsoever and I'll just go to a project exchange site.

                  I just figured that I spent all day with this while I'm sure a pro could do it all in a couple of hours and I have better things to do with my time than learn AS3 for what is really just a little toy for us...

                  Cheers :)

                  Chris
                  • 6. Re: Apply font styles to text field
                    SymTsb Level 2
                    Chris, e-mail me mike@sd-dezign.com I'm not offended at all. I can look at the file and we can go from there.