A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: Loading image into a dynamic text field

  1. #1
    Junior Member
    Join Date
    Sep 2004
    Posts
    12

    Loading image into a dynamic text field

    I need to be able to display images in a dynamic text field using HTML. I have MX2004, and it's supposed to be possible.

    Here is basically the code I am currently trying to use:

    PHP Code:
    myText_txt.html=true;
    myText_txt.htmlText "<img src='../external/mindbutton.jpg' id='link01' width='88' height='31'>"
    Unfortunately that doesn't display the image at all. I've double and triple checked to make sure that URL is right also, and it is. Is there something that I'm missing?

  2. #2
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    sometimes it doesnt like an img alone (so add the &nbsp;) ; also changed ' to \ (escape slashes are safer). try this
    code:

    myText_txt.html=true;
    myText_txt.htmlText = " &nbsp;<img src=\"../external/mindbutton.jpg\">"


  3. #3
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Make sure the .jpg is not progressive as well I guess!

  4. #4
    Junior Member
    Join Date
    Sep 2004
    Posts
    12
    Many thanks moagrius. It works now!

  5. #5
    ___________________
    Join Date
    May 2004
    Posts
    3,174

  6. #6
    Junior Member
    Join Date
    Sep 2004
    Posts
    12
    Hrm... problems again -_- Before, I was doing it in a seperate swf to get it working before i tried to make it work w/ the site i'm building. It worked great in the test swf I made. But, now that I put it into my actual movie, it's no longer working. -_-

    code:
    right_txt.html = true;
    right_txt.wordWrap = true;
    right_txt.multiline = true;
    right_txt.label.condenseWhite=true;
    right_txt.htmlText = " &nbsp;<img src=\"../external/mindbutton.jpg\">"



    Is it normally this buggy? Or is it just me..

  7. #7
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    proably the path

    assuming the jpg and both swfs are in the same folder, you don't need any dots or preceding slashes

    just
    code:

    right_txt.html = true;
    right_txt.wordWrap = true;
    right_txt.multiline = true;
    right_txt.label.condenseWhite=true;
    right_txt.htmlText = " &nbsp;<img src=\"mindbutton.jpg\">";


    or if the folder "external" is in the same folder the swfs are in
    code:

    right_txt.htmlText = " &nbsp;<img src=\"external/mindbutton.jpg\">";



    also noticed no terminating semi-colons? they're included in the two codes i just gave

  8. #8
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    Originally posted by Jaelle_MJ
    Hrm... problems again -_- Before, I was doing it in a seperate swf to get it working before i tried to make it work w/ the site i'm building. It worked great in the test swf I made. But, now that I put it into my actual movie, it's no longer working. -_-

    Code:
    right_txt.html = true;
    right_txt.wordWrap = true;
    right_txt.multiline = true;
    right_txt.label.condenseWhite=true;
    right_txt.htmlText = " &nbsp;<img src=\"../external/mindbutton.jpg\">"
    Is it normally this buggy? Or is it just me..
    hmm what's that bit in red?

  9. #9
    Junior Member
    Join Date
    Sep 2004
    Posts
    12
    the condenseWhite is supposed to take out extra white space. Eventually i'm going to be loading an xml file into that text box, but I haven't gotten that far yet, since the image refuses to work.

    I'm 99.9% sure the path is right. My directory structure is like this:

    /flash/file.swf
    /external/image.jpg

  10. #10
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    lol, i know what condenseWhite does ya kook

    i meant... everything so far has been

    code:

    right_txt.something



    but now there's that one phantom
    code:

    right_txt.label.something


  11. #11
    Junior Member
    Join Date
    Sep 2004
    Posts
    12
    It was supposed to fix a possible formatting problem that can occur w/ the xml. However, it seems to work fine w/out it as well. The image still doesn't show up either way though.

  12. #12
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    hmmm ok what i'm saying is... that means you're referencing something else, an mc or textfield named "label" which makes me wonder if we're targetting the right thing

    go here

    http://qfiles.iamyourhost.com/fkstest/jaelle.html

  13. #13
    Junior Member
    Join Date
    Sep 2004
    Posts
    12
    Ok... now I'm confused. So I just tried to make it simpler. The label.condenseWhite there isn't causing me any problems as of yet. I take it out completely and it still works fine. The image still doesn't appear tho.

    I'm going to attempt to explain again in more detail.


    The non-simplified version of what I have in my movie is:
    code:

    right_txt.html = true;
    right_txt.wordWrap = true;
    right_txt.multiline = true;
    if(content_xml.firstChild.childNodes[i].attributes.type=="links") {
    right_txt.htmlText = "<ul><li><a href=\""+content_xml.firstChild.childNodes[i].firstChild.firstChild+"\">"+content_xml.firstChil d.childNodes[i].firstChild.attributes.header+"</a> &nbsp;<img src=\"../external/mindbutton.jpg\"></li></ul>";
    trace(right_txt.htmlText);
    }



    I used trace to see what exactly it was reading. It returns:

    Code:
    <TEXTFORMAT LEADING="2"><LI><FONT FACE="Arial" SIZE="14" COLOR="#000033"><A HREF="http://www.undeadninja.com/unmindful/unmindful.html" TARGET="">Unmindful</A>  </FONT></LI></TEXTFORMAT>
    As you can see, it doesn't seem to like the idea of the image being in there. And it obviously doesn't show up either.

  14. #14
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    maybe this'll help
    open a new fla, paste this in frame 1, publish, save, close.
    code:

    var z:Number = 0;
    var tf:TextFormat = new TextFormat();
    //add your text formats here
    this.createEmptyMovieClip("table", ++z);
    function textblock(n, x, y, s) {
    var k = _level0.table.createEmptyMovieClip(n, ++z);
    k.createTextField("tx", 0, x, y, 220, 15);
    k.tx.html = true;
    k.tx.htmlText = s;
    k.tx.setTextFormat(tf);
    }
    var x:XML = new XML();
    x.ignoreWhite = true;
    x.load("jaelle.xml");//change jaelle.xml to the name of your xml sheet
    x.onLoad = function(success) {
    if (success) {
    for (i=0; i<x.childNodes.length; i++) {
    j = i*80;
    textblock("fieldA"+i, 0, j, x.childNodes[i].childNodes[0].childNodes);
    textblock("fieldB"+i, 0, j+15, x.childNodes[i].childNodes[1].childNodes);
    textblock("fieldC"+i, 0, j+30, x.childNodes[i].childNodes[2].childNodes);
    textblock("fieldD"+i, 0, j+45, x.childNodes[i].childNodes[3].childNodes);
    textblock("pic"+i, 300, j, "<img src='"+x.childNodes[i].childNodes[4].childNodes+"'>");
    }
    }
    };



    and your xml sheet is formatted like this
    Code:
    <emptyplatitude><field100>maple</field100><field200>syrup</field200><field300>is</field300><field400>tasty</field400><field500>images/picoftastymaplesyrup.jpg</field500></emptyplatitude>
    <emptyplatitude><field100>pixel</field100><field200>fonts</field200><field300>are</field300><field400>for girls</field400><field500>images/girlinpinkdress.jpg</field500></emptyplatitude>
    <emptyplatitude><field100>i'm</field100><field200>out</field200><field300>of</field300><field400>ideas</field400><field500>dumbguy.jpg</field500></emptyplatitude>

  15. #15
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    - The right of the People to create Flash movies shall not be infringed. -

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