A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: diplaying html in a dynamic txt field

  1. #1
    like my brain
    Join Date
    Nov 2005
    Posts
    16

    diplaying html in a dynamic txt field

    Hi folks! Im in dire need of some help on this one.

    I have a movie that i load external swf's into at run time into a target mc. This works fine....

    HOWEVER!!....

    In the external swf's, i have mc's on the main timeline that act as pages. Inside these mc's i have a dynamic txt field. On the first frame of each mc i have

    this.loadVariables("http://www.website.com/external.txt");

    The txt field has the same variable name as the variable inside "external.txt"

    This works perfectly if i leave it as a plain text chunk (done in notepad), but i need to format the text in the external file as html and have that display properly inside the dynamic txt field...

    Ive browsed through a few tutes but have had no luck and was hoping some old hands could help out a bumbling newbie!!

    Much appreciated

    Clearmedia

  2. #2
    Getting There! bitsk308's Avatar
    Join Date
    Jul 2000
    Location
    Phoenix, AZ
    Posts
    427
    There are a number of things that could be the problem. First off, flash doesn't support but the most basic html tags for formatting, so don't get to crazy there. Of course, yourTextField.html = true needs to be set. Fonts need to be embedded. Does it matter that it's in a loaded swf, not the main. I mean does it work ok when you run the loaded swf on it's own and not inside your root movie. It's hard to know if the problem is there or in your text formatting.

    Maybe post your .flas so we can take a look

    _b

  3. #3
    like my brain
    Join Date
    Nov 2005
    Posts
    16
    thanks for the prompt reply. I know it must be simple, too many hours staring at the screen getting frustrated!!

    here's the fla...see if you can set me right.

    thanks again
    Attached Files Attached Files

  4. #4
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    you have too many (and unsupported) formatting HTML tags. you need to strip it down to the basics.... none of your mc's have instance names either.. if you give them instance names, you can use loadVars() to load your text like this:
    Code:
    var my_lv = new LoadVars();
    my_lv.onLoad = function() {
    	salsa_txt.html = true;
    	salsa_txt.htmlText = this.salsa;
    	//trace(this.salsa);
    };
    my_lv.load("http://www.vaticanbar.com/test/wednesdays.txt");
    //
    //this.loadVariables("http://www.vaticanbar.com/test/wednesdays.txt");
    strip down your txt files more like this:
    Code:
    &salsa=<font color="#CC0000">Melbourne's hottest and sexiest night,where you can leave your inhibitions at the door and let the atmosphere and poeple of the night bring out the best of you with sounds of smooth sexy salsa in addition of funky RnB, Reggaeton and House beats.</font>Attractive shows and 5 star customer service to patrons to this exclusive night have indeed contributed to the name of this night, and for patrons that wish to learn this unforgetable exotic dance can participate in our early dance lessons performed by Melbourne's most biggest and well known dance schools.
    
    <font color="#FFCC66"><a href="http://www.cubandanceacademy.com.au">www.cubandanceacademy.com.au</a></font>
    
    <font color="#CCCCCC">Melbourne's hottest and sexiest night,where you can leave your inhibitions at the door and let the atmosphere and poeple of the night bring out the best of you with sounds of smooth sexy salsa in addition of funky RnB, Reggaeton and House beats. Attractive shows and 5 star customer service to patrons to this exclusive night have indeed contributed to the name of this night, and for patrons that wish to learn this unforgetable exotic dance can participate in our early dance lessons performed by Melbourne's most biggest and well known dance schools.</font>
    
    <font color="#CC0000"><a href="http://www.cubandanceacademy.com.au">www.cubandanceacademy.com.au</a></font>
    &
    hope that helps....
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

  5. #5
    like my brain
    Join Date
    Nov 2005
    Posts
    16
    thanks heaps dude! i'll give it a whirl and get back to you

  6. #6
    like my brain
    Join Date
    Nov 2005
    Posts
    16
    sorry again....in your example code, is the instance name salsa?

  7. #7
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    notice in madz example that the onLoad function refers to this.salsa. Inside a loadvars command, this refers to the loadvars object itself which now has html data tied to a variable called salsa.

    Also FK adds extra hard returns in code posts so ignore the extra hard returns.

  8. #8
    like my brain
    Join Date
    Nov 2005
    Posts
    16
    cheers again!

    ohhh how much i have to learn!

  9. #9
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    I learned it all here too :P
    Read this guys books too. Really speeds up the learning process.
    http://www.moock.org

  10. #10
    like my brain
    Join Date
    Nov 2005
    Posts
    16
    ive inserted the said code but still nothing.

    can someone have a look at these and explain how what when and where!!!

    cheers again!!
    Attached Files Attached Files

  11. #11
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    it's your .txt file that you need to change..... i used the first file you posted, created a new text file starting &salsa=blah bah blah. and then using loadVars() exactly as i have it posted above, loaded the text no problem. Strip out all of your HTML tags except for <font size="XX" color="#XXXXXX"></font> | <br /> | <b> </b>|<a href =""></a> Flash doesn't support a whole lot more than those consistently. If you are embedding fonts and intend to use BOLD type at all.. make sure you embed the bold chars as well...
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

  12. #12
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    here.. i fixed it for you....
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

  13. #13
    Senior Member
    Join Date
    Oct 2000
    Location
    Jersey Shore | USA
    Posts
    294
    or you could load an actual HTML file instead of a text file into your dynamic text boxes, I've just done it with the following info:

    actionscript for text box frame:
    Code:
    var ss:TextField.StyleSheet = new TextField.StyleSheet();
    ss.load("html_files/dcgsa.css");
    text_a.styleSheet = ss;
    
    text_a.multiline= true;
    text_a.wordWrap = true;
    text_a.html = true;
    
    story = new XML();
    story.ignoreWhite = true;
    story.load("html_files/a.html");
    story.onLoad = function () {	
    	text_a.htmlText = story;
    }
    where 'text_a' is the instance name for the text box and 'html_files/a.html' is the location and file name. I've got 7 or 8 of these on my flash projector file and they are all named with different instances, text_a, text_b, etc. One CSS sheet controls all the looks for all the HTML files. And yes, all the HTML code is stripped to the bare minimum. Oh yea, and this way you don't have to worry about the VARS in the text file.

    Works like a charm.

  14. #14
    like my brain
    Join Date
    Nov 2005
    Posts
    16
    thankyou all sooo much!!! it seems to be working fine. Thanks Madzigian for doing that...i owe you one! Looks like i'll be getting that cheque pre xmas after all


    LOVE YOU ALL!!!!!!!!

  15. #15
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    Looks like i'll be getting that cheque pre xmas after all
    --- my cut is 10%!!!

    no problem though.. happy to help.

    GL
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center