Created
July 8, 2011 01:15
-
-
Save ayush/1070905 to your computer and use it in GitHub Desktop.
wordnik-as3-sdk audio prons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import com.wordnik.api.client.WordnikClient; | |
import com.wordnik.api.entity.ApiUserCredentials; | |
import com.wordnik.api.entity.Word; | |
import com.wordnik.api.entity.word.AudioFileInfo; | |
import com.wordnik.api.event.ApiClientEvent; | |
import com.wordnik.api.event.Response; | |
import flash.display.Sprite; | |
import flash.text.TextField; | |
import flash.text.TextFieldAutoSize; | |
import flash.text.TextFormat; | |
public class Main extends Sprite | |
{ | |
private const textfield:TextField = new TextField(); | |
private const format:TextFormat = new TextFormat(); | |
private const apiKey: String = "your-api-key"; | |
private const hostName: String = "api.wordnik.com"; | |
public function Main() | |
{ | |
initUi(); | |
// Instantiate a WordnikClient | |
var wordnikCredentials: ApiUserCredentials = new ApiUserCredentials(this.apiKey); | |
wordnikCredentials.hostName = this.hostName; | |
const wordnikClient: WordnikClient = new WordnikClient(wordnikCredentials); | |
wordnikClient.addEventListener(ApiClientEvent.AUDIO_INFO_RESPONSE_EVENT, onAudioInfoRequestCompleted); | |
wordnikClient.getAudioInfo("freedom"); | |
} | |
private function onAudioInfoRequestCompleted(event: ApiClientEvent, requestId: String = null):void { | |
var result: Response = event.response; | |
var wordnikWord: Word = result.payload as Word; | |
showText(""); | |
showText("Audio Urls"); | |
for(var i: Number = 0; i < wordnikWord.audioMetadata.length; i++) { | |
var audioInfo: AudioFileInfo = wordnikWord.audioMetadata[i] as AudioFileInfo; | |
showText(" - " + audioInfo.fileUrl); | |
} | |
} | |
private function initUi(): void { | |
textfield.width = 200; | |
textfield.height = 300; | |
textfield.text = "Properties of freedom"; | |
textfield.y = 0; | |
textfield.x = 0; | |
textfield.border = true; | |
textfield.background = true; | |
textfield.multiline = true; | |
textfield.wordWrap = true; | |
format.color = 0x666666; | |
format.size = 8; | |
textfield.defaultTextFormat = format; | |
textfield.setTextFormat(format); | |
addChild(textfield); | |
} | |
private function showText(s: String): void { | |
textfield.appendText(s + "\n"); | |
trace(s); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment