1

I have a desktop chat app and a text field would add images (typical emoticons) and what can not do wrong that I can not display any images. Use a file in which text is stored chat, which divided by lines on a table and then analyzed. What I do is when I send an emoticon, I select a folder and sending its location to chat and then I check to display the selected image as appropriate. But I do not get to see anything.

    public function newchat8()
    {
        msgArray8 = new Array;
        msgArray8 = elmsg2.split("\n");
        ii=Number(msgArray8.length);
        ii--;
        mi_formato.size=15;
        loschat8=new TextField;
        loschat8.height = 500;
        loschat8.width = 400;
        loschat8.multiline = true;
        loschat8.wordWrap = true;
        loschat8.setTextFormat(mi_formato);
        for (i=0; i<ii; i++)
        {
            newchat_b8();
            comprobar_enlace8();
        }
        loschat8.scrollV=loschat8.maxScrollV;
    }

    public function newchat_b8()
    {
        swusuario = msgArray8[i].indexOf(usuariob);
        if (swusuario != -1)
        {   elcolor2 = elcolor;     }
        else
        {   elcolor2 = "#151515";   }

        loschat8.htmlText=loschat8.htmlText + '<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="20" COLOR="' + elcolor2 + '"  ><b>' + msgArray8[i] + '</b></FONT></P>';
        //loschat8.htmlText=loschat8.htmlText + msgArray8[i];
    }

    public function comprobar_enlace8()
    {
        swlink = msgArray8[i].indexOf("z:/intranet/emoticonos/");
        if (swlink != -1)
        {
            swlink2 = Number(msgArray8[i].length);
            elmsg4="<img src='carita.jpg' width='50' height='50'>"; 
            loschat8.htmlText=loschat8.htmlText + elmsg4;

        }
        loschat8.scrollV=loschat8.maxScrollV;
    }
  • Your image should be accesible via Internet or embedded into your SWF in order to be displayed in a textfield. You here have a local filesystem path to check, and an unspecified path to the image, this means your image should be located in the same folder as the SWF if you're viewing the page with the SWF via http link. – Vesper Jul 06 '15 at 11:39
  • Thanks for the reply. The image is embedded in the swf and have put it in the folder swf, both ways is not going. In fact the code is put well, what you mean is a brand that seeks to know the message bearing an image.   elmsg4 = "";              loschat8.htmlText = loschat8.htmlText + elmsg4; I really do not understand because I've tried every way, embedded in the swf folder, searching in a web and not going. – Manuel Seijas Cortés Jul 06 '15 at 13:21
  • I'm not sure if Flash handles directories the same as browsers do. Does putting the full directory of your image change anything? – David Jul 06 '15 at 14:15
  • Hello. I put so much without "carita.jpg" "./carita.jpg" "c: /temp/carita.jpg" or "http://www.bretemapro.com/carita.jpg" gives the same result, nothing comes out. It's very strange. – Manuel Seijas Cortés Jul 06 '15 at 14:38
  • @ManuelSeijasCortés May be you have a problem with the image file, try another one ! – akmozo Jul 06 '15 at 14:42
  • And I did !!!! It's very strange. – Manuel Seijas Cortés Jul 06 '15 at 15:15
  • You might probably need to close the `` tag as well, and see my answer on how to organize your image into your app. Question to refer to: http://stackoverflow.com/questions/14134392/flash-actionscript-how-to-insert-images-in-dynamic-text-in-line-image http://stackoverflow.com/questions/12068933/using-symbol-from-library-in-htmltext-img-tag-in-actionscript-3 – Vesper Jul 07 '15 at 07:27

1 Answers1

0

In order to make an image visible in your TextField, you should do one of these two things:

  1. Place an image in the same folder where your SWF is located. Refer to image as <img src="filename.jpg" ... /> in your text field's htmlText string.
  2. Embed an image as a bitmap, assign a class name to it (either as a library item in Flash CS, or as a [Embed] structure in FlashDevelop, whichever applies to you). Refer to the image as its class name: <img src="ClassName" ... />

The first approach requires that the referred file should be accessible by the browser, as it will generate an URL request for that file, using the full path to the SWF as base for relative path to the image, say http://www.example.com/MyProject/carita.jpg, and if there would be no file by that path, you won't see an image. The second approach does not require anything, as the data is already loaded within the SWF. So, you should have a library object in your FLA with type Bitmap and a defined name, and use that name as source for "img" tag.

Vesper
  • 18,599
  • 6
  • 39
  • 61
  • 1
    I tried everything you've shown me, but nothing works. Is it because it's a desktop app? I'm using Flash Professional AIR CC 2015 and 17.0 do not understand anything. – Manuel Seijas Cortés Jul 07 '15 at 11:27
  • What do you mean by "nothing works"? Trace if the function is ever reached, and trace if the `htmlText` is changed, maybe you have troubles elsewhere. – Vesper Jul 07 '15 at 11:35
  • The textfield working properly, control instructions to change the color and appearance of text, hyperlinks, but can not get an image is displayed. – Manuel Seijas Cortés Jul 07 '15 at 13:09
  • Did you check that the `` tag is actually in the text field's `htmlText`? Maybe you have a bug in calling the function. I doubt that there are no errors in that, because of the local path string in its code. – Vesper Jul 07 '15 at 13:27
  • Of course, it is incomprehensible situation, I do not understand why the image is not displayed. – Manuel Seijas Cortés Jul 07 '15 at 15:11
  • What is your compile target? AIR, ANE, Flash (desktop)? While yes, the issue looks very strange. – Vesper Jul 07 '15 at 15:13
  • Thanks for your interest. This is an AIR desktop application. – Manuel Seijas Cortés Jul 08 '15 at 07:19
  • Vesper, just did a test, if the target is a desktop app Flash Player images in AIR desktop are not seen. But my app does not work on Flash, I get lots of errors with instructions concerning files. – Manuel Seijas Cortés Jul 08 '15 at 10:37