Skip to main content
Inspiring
March 13, 2014
Question

Load image in array

  • March 13, 2014
  • 1 reply
  • 1147 views

Hi all,

I'd like to load an image with a definiton for each word I type in my search bar.

So far, the text definition is working but I can't load images..

Here's my code :

private var DefinitionArray:Array = [

                    {label:"Definition1", Text:"It's the text 1",  Image: {url:"assets/smiley.jpg"}},

                    {label:"Definition2", Type:"It's the text 2", Image: {url:"assets/smiley2.jpg"}}];

And when setDisplay is called :

private function setDisplay(e:Event):void{

                              var fIndex:int = ac.aIndex;

                                        it1.htmlText = "<b>Définition :</b><br /> "  +  DefinitionArray[fIndex].Type +"<b>image :</b><br /> "  +  DefinitionArray[fIndex].Image.url;

                                        it1.setTextFormat(titleFormat);

                    }

Here's what I got as a result :

Do you know what could be the problem ?

Thank you very much,

-------

EDIT

And if I change

DefinitionArray[fIndex].Image.url

by

DefinitionArray[fIndex].Image


I've got this :

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
March 13, 2014

As you have it you are defining the Image.url as a String, and that is what you are telling it to show, the string.  If the intention is to use load the image as an html entity then you are forgetting to incorporate the html <img> tag.  See the htmlText property of the TextField class for further information...

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextField.html#htmlText

Inspiring
March 13, 2014

Thanks, but

{label:"Definition1", Text:"It's the text 1", Image: "<img src='smiley.jpg'/>"},

don't work either....

Don't see the image :

Ned Murphy
Legend
March 13, 2014

I don't know for sure regarding the AIR matter.  That has to do with sandboxes and I believe you are within the same one in your situation.

But the way you specified the image string is likely wrong in a couple ways.  The previous version of it included a folder in the url, so you might be mistargeting the image.  Also if you are creating a string, you probably need to use the escapr character for the escape character that you have...

something like...

"<img src='assets//smiley.jpg' //>"