6 Replies Latest reply on Jul 23, 2008 9:58 AM by cayohueso2

    HTML with image and Flash

    cayohueso2
      Hi, I have a Flash file with the following code in it:

      // Create a new style sheet object and set styles for it.
      var styles:TextField.StyleSheet = new TextField.StyleSheet ();
      styles.setStyle ("html",{fontFamily:'Arial,Helvetica,sans-serif', fontSize:'12px', color:'#0000FF'});
      styles.setStyle ("body",{color:'#00CCFF'});
      styles.setStyle ("h1",{fontFamily:'Arial,Helvetica,sans-serif', fontSize:'24px', color:'#006600'});
      styles.setStyle ("p",{color:'#000000', fontSize:'14px'});
      styles.setStyle ("a",{color:'#0000FF', fontSize:'14px', fontWeight:'bold', textDecoration:'underline'});
      //
      /* Assign the style sheet object to myTextArea component. Set html property to true, set styleSheet property to the style sheet object. */
      myTextArea.styleSheet = styles;
      myTextArea.html = true;
      myTextArea.focusTextField = null;
      //

      var myVars:LoadVars = new LoadVars ();
      // Define onData handler and load text to be displayed.
      myVars.onData = function (myStr:String):Void {
      if (myStr != undefined) {
      myTextArea.text = myStr;
      } else {
      trace ("Unable to load text file.");
      }
      };
      //
      myVars.load ("references.htm");
      //

      THEN, I have the file references.htm to be loaded:

      <p>Text text text. <br/>[<img src='images/imagepopup.gif' width='15' height='15' vspace='0' hspace='0'/><a href=" http://www.cnn.com" target="_blank">Link to CNN</a>]</p>

      The problem is that the image that is in the HTML code does not appear in the same line with the text (inside the []). Instead, it appears in a line below.

      It looks like this:
      Text text text.
      [ Link]
      Image

      But it should look like this:
      Text text text.
      [Image Link]


      Is there anything wrong with the code? Please advice.
      Thanks,
      CH

        • 1. HTML with image and Flash
          robdillon Most Valuable Participant
          This is an html problem. you need to wrap the image tag with its own a href tag. Something like this might be what you want:
          • 2. Re: HTML with image and Flash
            cayohueso2 Level 1
            I tried your recommendation, but unfortunately it does not work when you add square brackets []

            it works without them, but I need to use them.

            Do you have any suggestion?

            Thanks

            • 3. Re: HTML with image and Flash
              robdillon Most Valuable Participant
              Is this a Flex thing? You might try adding an onMouseUp event to the image and call a javascript function to get the new url.
              • 4. Re: HTML with image and Flash
                cayohueso2 Level 1
                No, it is a Flash file.
                I got the answer below from another forum. Do you know if there is any way to work around this? Thanks

                "
                from the help docs:
                In general, an image embedded in a text field appears on the line following the <img> tag. However, when the <img> tag is the first character in the text field, the image appears on the first line of the text field."
                this means that if you say:
                textfield.htmlText = "<img src='image.jpg'>Text";
                it'll show the image then text directly to the right of it. however, if you put ANYTHING before the image tag, it'll cause the whole thing to break on lines, including the "Text" afterward that had previously appeared to the right.
                "
                • 5. Re: HTML with image and Flash
                  robdillon Most Valuable Participant
                  I just tried an example using AS2 and I get an image with text next to it using <p> tags for the text. I made no difference whether I add anchor tags or not.

                  I have no idea what purpose the brackets perform unless you just want to see them on the screen.

                  Where did that help docs quote come from?
                  • 6. Re: HTML with image and Flash
                    cayohueso2 Level 1
                    Hi,

                    The brackets are only to see them on the screen.

                    The Help quote is from:
                    Learning ActionScript 2.0 in Adobe Flash
                    Working with Text and Strings > Using HTML-formatted text > About embedding images, SWF files, and movie clips in text fields

                    Thanks,