Arrays 阵列生成图像

Arrays 阵列生成图像,arrays,actionscript,Arrays,Actionscript,我不太确定这是否可能,因为我不是一个频繁的程序员,但我有一个问题 我有一个数组,它在一个文本框中生成一个随机单词,然后第二个数组在另一个文本框中生成另一个随机单词。我想要的是,当数组1中的某个单词生成时,会出现一个特定的图像。代码如下: var firstChoice:Array = ["Do this", "Do that", "Do something else"]; var secondOption:Array = ["while doing this", "while doing tha

我不太确定这是否可能,因为我不是一个频繁的程序员,但我有一个问题

我有一个数组,它在一个文本框中生成一个随机单词,然后第二个数组在另一个文本框中生成另一个随机单词。我想要的是,当数组1中的某个单词生成时,会出现一个特定的图像。代码如下:

var firstChoice:Array = ["Do this", "Do that", "Do something else"];
var secondOption:Array = ["while doing this", "while doing that", "while doing something else"];
generate_btn.addEventListener(MouseEvent.CLICK, getTask);

function getTask(event:MouseEvent):void {
var randomChoice:Number = Math.floor(Math.random() * firstChoice.length);
var randomOption:Number = Math.floor(Math.random() * secondOption.length);
Final_Choice.text = firstChoice[randomChoice];
Final_Option.text = secondOption[randomOption];
}
例如,当我单击按钮,第一个数组生成“DoThis”时,我希望一个特定的图形与它一起出现


希望这是可能的:/我被难倒了

您可能需要使用HashMap,例如:

var map:Object = new Object();
map.first_choice = /*url of your image associated with this choice*/
map.second_choice = /*url of your image associated with this choice*/
//etc
当生成一个单词时,您只需使用foreach将该单词与地图的键进行比较,就可以得到图像的url