flash actionscript:
i have a portfolio application that uses a MediaPlayer component to play both
audio (MP3) and video (FLV) clips. when an image thumb is clicked in the
portfolio--either an image, a video clip, or an audio clip is displayed (images
are displayed in another MC). everything works fine--when selecting an audio
or video thumb, then the corresponding audio or video clip is loaded and played
in the MediaPlayer. but this only works once. any other time an audio or
video thumb is selected, the corresponding clip will not load and play.
below is the code i am currently using. resetMedia() is another function that
simply makes invisible the MediaPlayer and image display MC (and then one of
these will be turned back on to display content), and also stops any media
playback in MediaPlayer.
if (currentPicture.attributes.image != null) {
// image
currentThumb_mc.image = currentPicture.attributes.image;
currentThumb_mc.onRelease = function() {
_root.resetMedia();
content_holder.image_mc._visible = true;
content_holder.image_mc.loadMovie(this.image);
description_lv.load(this.description);
}
} else if (currentPicture.attributes.audio != null) {
// audio
currentThumb_mc.audio = currentPicture.attributes.audio;
currentThumb_mc.onRelease = function() {
_root.resetMedia();
content_holder.media_mc._visible = true;
content_holder.media_mc.setMedia("web_audio/Weekend_Players__Angel.mp3",
"MP3");
media_mc.play(0);
description_lv.load(this.description);
}
} else if (currentPicture.attributes.video != null) {
// video
currentThumb_mc.video = currentPicture.attributes.video;
currentThumb_mc.onRelease = function() {
_root.resetMedia();
content_holder.media_mc._visible = true;
content_holder.media_mc.setMedia("web_video/Coca_Cola_p.flv", "FLV");
media_mc.play(0);
description_lv.load(this.description);
}
}