我想创建一个使用 XML 加载一些数据的 flash 电影。当用户点击屏幕时,我希望每一行数据一个接一个地出现。到目前为止,我已将所有数据添加到屏幕上,但我不确定如何为此编写点击机制。
我尝试添加一个允许我单击以删除和对象的功能,如下所示:
muppet_name0.addEventListener(MouseEvent.CLICK, fl_ClickToKermit);
function fl_ClickToKermit(event:MouseEvent):void
{
muppet_name0.visible = false;
}
但我不确定如何让它重新出现。如何添加将删除对象同时添加新对象的 MouseClick 事件?
我的文档类如下
package {
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.MouseEvent;
public class MuppetsDoc extends MovieClip {
public var myData:XML = <data>
<item>
<a>Kermit the Frog</a>
<b>Jim Henson</b>
<c>1955</c>
</item>
<item>
<a>Miss Piggy</a>
<b>Frank Oz</b>
<c>1974</c>
</item>
<item>
<a>Animal</a>
<b>Frank Oz</b>
<c>1975</c>
</item>
<item>
<a>The Swedish Chef</a>
<b>Jim Henson/Frank Oz</b>
<c>1975</c>
</item>
</data>;
public function MuppetsDoc() {
// constructor code
//trace(myData);
//muppets_txt.text = myData.item[2].a.length();
var aTxt:String = myData.item[2].a.text();
muppet_name0.appendText(myData.item[0].a.text());
muppet_puppet0.appendText(myData.item[0].b.text());
muppet_year0.appendText(myData.item[0].c.text());
muppet_name1.appendText(myData.item[1].a.text());
muppet_puppet1.appendText(myData.item[1].b.text());
muppet_year1.appendText(myData.item[1].c.text());
muppet_name2.appendText(myData.item[2].a.text());
muppet_puppet2.appendText(myData.item[2].b.text());
muppet_year2.appendText(myData.item[2].c.text());
muppet_name3.appendText(myData.item[3].a.text());
muppet_puppet3.appendText(myData.item[3].b.text());
muppet_year3.appendText(myData.item[3].c.text());
}
}
}