A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: loading file with HTML

  1. #1
    Senior Member
    Join Date
    Mar 2004
    Location
    Upper Marlboro, MD
    Posts
    146

    loading file with HTML

    I'm having a very hard time trying to find examples and tutorial on loading a text file with HTML tags into a dynamic text box in Koolmoves. Can someone help me please.

    I have a dynamic text box in a movie clip named [txt1]. I want to load a .txt file named "AboutUs.txt". The text box includes some HTML tags also. Here is my text file:

    "<P>This is a test about us.</P>"
    "<P>For more info, contact:<a href="http://www.info@talytech.com">Taly Tech</P>"


    Also, I have the properties of the dynamic text box to accept html.

  2. #2
    Super Moderator
    Join Date
    Jun 2000
    Posts
    3,512
    In the examples that come with koolmoves or that can be downloaded from koolmoves.com/support.html, you will find one or more examples for loading html into a dynamic text box. You must pay attention to the flash export version.

    -----------------

    I looked at the examples and they are quite old.

    The main problem with your example is that the file needs to start with txt1.txt = (where txt1 is the name of the text box) and it needs to have a html extension. This will change depending on the flash export version. I searched in google for "load html dynamic text flash 8" and found links.
    Last edited by Bob Hartzell; 01-31-2011 at 08:25 AM.

  3. #3
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Hey Taly

    You need to just look at examples of using URLRequest and the loader class, there are a lot of examples. Just about every XML example I've done using something similar.

    Without getting too complicated and doing any error checking it's basically

    Actionscript Code:
    var myTextLoader:URLLoader = new URLLoader();

    myTextLoader.addEventListener(Event.COMPLETE, onLoaded);

    function onLoaded(e:Event):void {
    txt1.htmlText=e.target.data;
    }

    myTextLoader.load(new URLRequest("AboutUs.txt"));

    I might point out that one of the really great things about KM's AS3 support is you can look beyond this forum for help. Most AS3 examples can be used.
    Last edited by blanius; 02-01-2011 at 09:02 AM.

  4. #4
    Senior Member
    Join Date
    Mar 2004
    Location
    Upper Marlboro, MD
    Posts
    146
    can someone please help me.. please. i've been searching for a week now. I can't figure it out.

    I have a Koolmoves fun file with a movieclip named mc2. Also, I'm using AS 1.0

    On mc2 I have a dynamic text box with the default name [txt4] and the variable name is [txt4var]. I set the properties of the textbox to accept HTML.

    I have a text file named history.txt In that file is the following text:

    Code:
    &txt4var=Our National Organization, Las Amigas, Incorporated, was organized in Charlotte N.C. in 1957 by Dora R. Mason and Mary Q. Moore. Since that time twenty-six Chapters were established across the states from North Carolina  to Ohio.  Seat Pleasant is one of the twenty-six Chapters and is located in Maryland.
    For more info:
    
    <a href="http://www.lasamigasseatpleasant.org/">Visit Our Site</a>
    I am trying to load that file into my dynamic text box. I've tried several different ways:

    I've tried putting the following AS on the root of the mc2 that contains the textbox:
    Actionscript Code:
    loadVariables("history.txt",_mc2);

    That returns nothing.

    Then I tried the following:
    Actionscript Code:
    loadText = new LoadVars();
    loadText.load("history.txt");
    //creating the loadVarsText function
    loadText.onLoad = function() {
    txt4.htmltext = this.txt4;
    };

    This returns nothing. This is driving me crazy. Can someone please tell me what I'm doing wrong. Thanks in advance.

  5. #5
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193
    Taly,

    your code looks like what I have used except I put the "loadVariables" on the main movie. Have you tried that?

    On the main movie (not on the mc root)

    Actionscript Code:
    loadVariables("history.txt",_mc2);

  6. #6
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193

    Angry

    Quote Originally Posted by etuom View Post
    Taly,

    your code looks like what I have used except I put the "loadVariables" on the main movie. Have you tried that?

    On the main movie (not on the mc root)

    Actionscript Code:
    loadVariables("history.txt",_mc2);
    nope, i guess that doesn't work either

  7. #7
    Senior Member
    Join Date
    Mar 2004
    Location
    Upper Marlboro, MD
    Posts
    146
    etuom .. Thank you!!! I put it on the main movie, now it works.

  8. #8
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193

    Thumbs up

    Quote Originally Posted by talytech View Post
    etuom .. Thank you!!! I put it on the main movie, now it works.


    I tried to do an example and it didn't work for me...Glad it's working for YOU!

  9. #9
    Senior Member
    Join Date
    Mar 2004
    Location
    Upper Marlboro, MD
    Posts
    146
    lol .. if you put this on the main movie:
    Actionscript Code:
    loadVariables("history.txt",_mc2);

    That wouldn't work because you are referencing the movie clip.. I put this on the main movie:
    Actionscript Code:
    loadVariables("history.txt",_root);

    Thanks again ..

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