am working on a project to develop a thesaurus app using flash as3. However my app works fine but it only displays the synonym for the word already being put inside the thesaurus API url. However, I want my app to allow any user input through the input text field. Is there a way to do that? Many thanks in advance. I use "Big Huge Thesaurus API" for synonyms. For example in below API URL only synonyms for word "mother" are displayed.
" http://words.bighugelabs.com/api/2/958af28ac9e3b21c650cbdd24a2466e8/mother/ "
Here is my full code.
button1.addEventListener(MouseEvent.CLICK, loadScores);
function loadScores(e:MouseEvent):void {
var fileLoader:URLLoader = new URLLoader();
fileLoader.addEventListener(Event.COMPLETE, scoresLoadComplete);
fileLoader.load(new URLRequest("http://words.bighugelabs.com/api/2/958af28ac9e3b21c650cbdd24a2466e8/mother/"));
}
function scoresLoadComplete(evt:Event):void {
try {
var returnVars = evt.target.data;
highscores.htmlText = returnVars;
trace("Data retrieved successfully");
for (var myVars in returnVars) {
trace(myVars + ": " + returnVars[myVars]);
}
trace("***********************");
} catch (err:Error) {
trace("Can't parse loaded file: " + err.message);
}
}
Have an input text box in your application and set its instance name to "userinput" and change the following line in your code.
fileLoader.load(new URLRequest(" http://words.bighugelabs.com/api/2/958af28ac9e3b21c650cbdd24a2466e8/mother/ "));
to
fileLoader.load(new URLRequest(" http://words.bighugelabs.com/api/2/958af28ac9e3b21c650cbdd24a2466e8/ "+userinput.text+" /"));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.