接下来的代码是关于一个非常简单的幻灯片放映。点击后,我想显示一张图片(或 swf),同时让其他图片消失......这是我的代码,它工作正常,但在 btn3 中,当我点击时,第二张图片不会消失..我不知道为什么。你能教我一些新方法来充分重写我的代码吗?
import flash.display.Loader;
import flash.events.Event;
var my_first_swf_loading_ever:Loader=new Loader();
my_first_swf_loading_ever.load(new URLRequest('1.jpg'));
var my_second_pic:Loader=new Loader();
my_second_pic.load(new URLRequest('2.jpg'));
var my_3_pic:Loader=new Loader();
my_3_pic.load(new URLRequest('pictures/3.jpg'));
btn.addEventListener(MouseEvent.CLICK, clicked);
function clicked(evt:Event):void
{
if (contains(my_second_pic)) {
removeChild(my_second_pic);
if (contains(my_3_pic)) {
removeChild(my_3_pic);
}
}
my_first_swf_loading_ever.x=120;
my_first_swf_loading_ever.y=120;
addChild(my_first_swf_loading_ever);
}
btn2.addEventListener(MouseEvent.CLICK, clicked2);
function clicked2(evt:Event):void
{
if (contains(my_first_swf_loading_ever)) {
removeChild(my_first_swf_loading_ever);
if (contains(my_3_pic)) {
removeChild(my_3_pic);
}
}
my_second_pic.x=120;
my_second_pic.y=120;
addChild(my_second_pic);
}
btn3.addEventListener(MouseEvent.CLICK, clicked3);
function clicked3(evt:Event):void
{
if (contains(my_first_swf_loading_ever)) {
removeChild(my_first_swf_loading_ever);
if (contains(my_second_pic)) {
removeChild(my_second_pic);
}
}
my_3_pic.x=120;
my_3_pic.y=120;
addChild(my_3_pic);
}