actionscript 3 - changing the images according to the definition (array) -


i'm making small , funny dictionary.

so far, i've got search bar. when user enters word he's got definition. i'm wondering if it's possible associate image definiton.

here's code :

public class main extends sprite{          private var ac:autocomplete;         private var conteneurimage:loader = new loader();         private var image:urlrequest = new urlrequest("images/tannoy.gif");         conteneurimage.load(image);         private var fruitarray:array = [         {label:"a bloc", type:"très fort", description:"une boîte de achards"},          {label:"a fond", type:"vie", description:"loulou"},          {label:"dfgdf", type:"à grande vitesse.", description:"indique une vitesse"},          private var bg:sprite;         // couple of textfields         private var t1:textfield;         private var t2:textfield;         // input textfield show our search results         private var it1:textfield;         // couple of textformats         private var titleformat:textformat;         private var titleformatw:textformat;         // 2 variables hold our x , y positions         private var xpos:int;         private var ypos:int;   // whenever need see list component part of autocomplete class, event dispatched autocomplete class , picked in listdepth function         // takes our instance of autocomplete class - ac - , moves highest available depth, numchildren ( elements on stage ) - 1.         private function listdepth(e:event):void{             setchildindex(ac, numchildren - 1);         }          // function response event dispatched autocomplete class. takes results, or lack of them, , displays information in our it1 textfield         private function setdisplay(e:event):void{             var findex:int = ac.aindex;             if(findex == -1){                 it1.text = ac.noresult;                 it1.settextformat(titleformat);             }else{                 it1.htmltext = "<b>définition rapide :</b> " + fruitarray[findex].type + "<br/><br/><b>définition complète:</b> " + fruitarray[findex].description;                 it1.settextformat(titleformat);             }         } 

so, think it's possible associate image label ?

something like

 <img src="smiley.gif"> 

or in

it1.htmltext = "<b>définition rapide :</b> " + fruitarray[findex].type + "<br/><br/><b>définition complète:</b> " + fruitarray[findex].description; 

maybe add code tells go search image in line.

how think can ?

thx

i'd recommend 2 choices:

1) make class word (or other name make sense). in class make variable word or array of names if want. add variable image , other data you'd keep.

here's example:

package  {      import flash.display.movieclip;     import flash.display.loader;     import flash.events.event;     import flash.net.urlrequest;     import flash.display.displayobject;       public class word     {          public var en_name:string;         public var fr_name:string;          public var image:displayobject;         public var imageurl:string;          private var imageloader:loader;          public function loadimage():void         {             imageloader = new loader();             imageloader.contentloaderinfo.addeventlistener(event.complete, onimageloaded);             imageloader.load(new urlrequest(imageurl));         }          private function onimageloaded(e:event):void         {             imageloader.contentloaderinfo.removeeventlistener(event.complete, onimageloaded);             image = imageloader.content;             imageloader = null;         }     }  } 

now instead of string arrays make arrays of words. you'll able access names in different languages , image. i've included loader if want load image outside (or can assign image var directly). not scalable version dictionary, have freedom extend , improve see fit.

2) less elegant, - make arrays of strings , images. , when access array of name, fruitarray[4], can access image array same access point, fruitpicturearray[4]

hope helps!


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -