13 Replies Latest reply on Mar 28, 2008 2:54 PM by Greg Dove

    HTML inside Flash a joke?

    BeniRose Level 1
      I'm not really sure what's going on here...I've had some bad HTML tranlation on flash's behalf before, but never as bad as this. It seems all my carriage returns are getting displayed and all my <br> tags are being ignored. I'm setting htmlText for sure so that's not the issue here, and I've had to take my carriage returns out before via using a split and join (because of course, why would flash include a replace function by CS3?!) but now I just have one giant line of text because my BRs are getting ignored. I've tried adding select html tags (such as <html> and <body>) but they don't seem to do anything. I've even tried a straight up XHTML template, but it seems to just throw lots of carriage returns in the beginning. Maybe someone can take a look at my html page I'm loading in (using LoadVars object) and tell me what I'm missing because I'm just getting one straight line of text out of it, and that's only when I manually remove all the carriage returns.

        • 1. HTML inside Flash a joke?
          Greg Dove Level 4
          Flash may do things that you don't expect. But that doesn't mean its inconsistent or doing things wrong (most often its just that the expectations don't match the code).

          1. Flash only supports a limited subset of html. Other tags may do nothing or cause problems. Check the docs under htmlText for details. EDIT: Actually no, there is a dedicated section here: http://livedocs.adobe.com/flash/9.0/main/00000920.html#wp261591
          2.The carriage returns split and join you mention is related to differences in operating systems and editors like Notepad on windows which are very basic. Notepad for example includes two characters that represent a single line break each of which can be considered a line break by itself in other operating systems. So that is not flash's fault.
          3. LoadVars also expects urlencoded text.... which is exactly how a browser works for form submissions etc. That means that some characters need to be encoded. You can check what that should look like by doing this:
          trace(escape("<b>this is what a bold string should be encoded like</b>")). I think a lot of people would choose to pass html as CDATA inside xml, because it lets you use the original representation of the html (subject to (1) above)

          Beyond that, I can't recall offhand whether htmlText also converts carriage return or linefeed characters to <br/> tags as well.
          • 2. Re: HTML inside Flash a joke?
            BeniRose Level 1
            Hey thanks. I actually realized I am doing something different, which is using the LoadVars Object, which I thought would be better, but apparently as you said, it expects url encoded text, which is not an option, so I'll have to go back to using the loadVariables function or find some way to escape it.

            As for the carriage return, it is irrelevant to my operating system. It's actually both on Windows and OSX, but that's not the point. The point is that when interpreting HTML, carriage returns should be ignored. I understand that Flash only displays a subset of HTML, but ignoring whitespace is one of the key principles of a markup language and cannot be ignored no matter how small the subset is. And br tags...come on!

            But anyways, thanks for the reply, it was helpful in getting this working.
            • 3. HTML inside Flash a joke?
              Greg Dove Level 4
              The carriage return problem is not related to the operating system that flash plays on. It is normally just related to the operating that created the original text files, namely:windows. The extra carriage returns are a property of the source file, and flash just reads them. But I think that's a separate issue, you're right.

              loadVariables should do exactly the same thing. If you want to load raw text you can do it with LoadVars. But you need to use the onData handler, and intercept the raw text before its attempted to be decoded. In that case you don't get a variable that is a property of the LoadVars instance.

              This can be handy, and probably will be what you want to do here after giving it some thought. I have also used this approach to decode json encoded data from php for example.

              Did you set the textfield's html property to true (assume you did)



              • 4. Re: HTML inside Flash a joke?
                BeniRose Level 1
                Hey thanks, I'll take a look into that onData to see if I can grab the HTML before it gets parsed into what seems to be plain text. My BR tags aren't even showing up in the text as if it's getting URL Encoded, they're just getting ignored. And you're right, plain and simple: regardless of how many or what kind of carriage returns whatever text editor being use on whatever operating system are being placed into my file, flash should be ignoring them when displaying "HTML", as this is a general principle of HTML and any markup language for that matter (It's called a markup language because the mark-up, aka code, formats the text, not the formatting of the mark up).

                I am indeed setting html attribute on my textbox. Thanks for your help, I'll look into it more and post my findings.
                • 5. Re: HTML inside Flash a joke?
                  BeniRose Level 1
                  Also, I realized loadVariables() won't work for me because I need to strip out all carriage returns when the text loads in and I can't do that with out event handling.
                  • 6. Re: HTML inside Flash a joke?
                    BeniRose Level 1
                    So I really have absolutely no idea what's going on here. I'm using the onData event handler, which seems to be more what I want, because I don't even need to set a key/value pairing, I can just put the html straight in the text file and it will load that as the src variable passed to my function.

                    So anyways, I traced what I'm assigning to my content_txt textfield right before I assign it, and then afterwards do an immediate trace on content_txt.htmlText and it's completely different. Here's what I'm getting, the first is what is coming from the page I'm loading in, and the second is what I'm getting back as being the htmlText the textfield. I've even tried it with and without the HTML and BODY tags.

                    <html><body>So this is my page, hope you enjoy!<br>Check out this <a href=" http://benrosenbach.com">link</a>.<br>testthis should be on the same line<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />ok<br /><br /><br /><br /><br /><br />this is dumb<br /><br /><br />yup.</body></html>

                    <TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Helvetica" SIZE="13" COLOR="#FFFFFF" LETTERSPACING="0" KERNING="0">So this is my page, hope you enjoy!Check out this <A HREF=" http://benrosenbach.com" TARGET="">link</A>.testthis should be on the same lineokthis is dumbyup.</FONT></P></TEXTFORMAT>

                    And here you can see my code:

                    • 7. Re: HTML inside Flash a joke?
                      MonteKrause Level 1
                      you might want to use <p> and </p> instead of <br /> ... Is your page encoded as XHTML or HTML
                      • 8. Re: HTML inside Flash a joke?
                        MonteKrause Level 1
                        you might want to use <p> and </p> instead of <br /> ... Is your page encoded as XHTML or HTML
                        • 9. Re: HTML inside Flash a joke?
                          Greg Dove Level 4
                          Hang on, I'll pull a working example together and post it online somewhere. Check back in about 15 mins.
                          • 10. Re: HTML inside Flash a joke?
                            Greg Dove Level 4
                            http://forums.flashgods.org/viewtopic.php?f=19&t=249

                            Check out that link there's a working example there for both ways to do it
                            • 11. Re: HTML inside Flash a joke?
                              Greg Dove Level 4
                              Oh and the other important thing I rediscovered for <br> and <p> tags etc is to make sure your textfield's multiline property is set to true. Also mentioned in the docs.
                              • 12. Re: HTML inside Flash a joke?
                                BeniRose Level 1
                                That was it. Multiline. I swear I had it on before, but I knew it had to be something dumb because I've gotten this working before! Thanks for your patience guys.

                                And I would also normally put this in XML and load it in that way, but the site is going to be managed by a band that "knows HTML" so I couldn't really confuse them more than they already are confused!
                                • 13. Re: HTML inside Flash a joke?
                                  Greg Dove Level 4
                                  Pleased to hear its solved.