当我点击第一个时,我不确定如何将一个影片剪辑替换为另一个影片剪辑。下面是我的代码,显示我加载第一个movieClip并将其添加到舞台并分配OnClick侦听器。
thumbs_button.addEventListener (MouseEvent.CLICK, playVideoButton);
for (var i:Number = 0; i < my_total; i++) {
var playButton_url = "play_now.png";
var playButton_loader = new Loader();
playButton_loader.name = i;
playButton_loader.load (new URLRequest(root_path + playButton_url));
playButton_loader.contentLoaderInfo.addEventListener (Event.COMPLETE, playButtonLoaded);
}
function playVideoButton (e:MouseEvent):void {
trace("Button " + e.target);
//thumbs_button.removeChild(e.target);
var video_url = root_path + my_videos[e.target.name].@URL;
my_player.source = video_url;
}
function playButtonLoaded (e:Event):void {
var my_playButton:Loader = Loader(e.target.loader);
thumbs_button.addChild (my_playButton);
}
答案 0 :(得分:0)
我不确定为什么你在一个movieclip(thumbs_button)中使用for循环多次加载图像(“play_now.png”),但是这里是删除加载图像的方法:
var playButton_url = "play_now.png";
var playButton_loader = new Loader();
playButton_loader.name = "play_now";
playButton_loader.load (new URLRequest(root_path + playButton_url));
thumbs_button.addChild(playButton_loader);
function playVideoButton (e:MouseEvent)
{
thumbs_button.removeChild(thumbs_button.getChildByName("play_now"));
}