MediaDisplay and Complete Event Gunk
I’m working on a small project that plays an FLV file using the MediaDisplay component. I’ve got a background clip behind it. If the user clicks the background clip or the “complete” event occurs the file returns to the main menu. The only problem is that if the “complete” event occurs, when I try to play the flv again it doesn’t work. When clicking out using the background it plays again fine. You can see my debug statement and that always returns the correct path. I’ve also used a static MediaDisplay component plunked down on the stage without the attachMovie bit with the same results.
The example uses the MDM Zinc player, which is why some of the code looks a but funky, but I also tried with a regular swf and had the same problem.
Has anyone out there run into this problem where the complete event causes the component to stick?
import mx.controls.MediaDisplay;
//mdm.prompt(fsp_appdir + “files” + pres.video.file);
stop();
var mdVideo:MediaDisplay;
mdVideo = MediaDisplay(this.attachMovie(“MediaDisplay”, “mdVideo”, 1000, {_x:112, _y:185}));
mdVideo.addEventListener(“change”, this.videoChange);
mdVideo.addEventListener(“complete”, this.videoComplete);
mdVideo.setMedia(fsp_appdir + “files” + pres.video.file, “FLV”);
mcVideoBackground.onRelease = function():Void {
this._parent.videoComplete();
};
function videoComplete():Void {
mcVideoBackground.onRelease = function():Void {};
mdVideo.removeMovieClip();
delete mdVideo;
gotoAndPlay(“video out”);
};
Should be simple but I guess not!
3 comments so far
Comments are closed.




awe man, you where the first to comment in my new blog and I accidently deleted your comment! IM A LOSER! lol
I have had funkyness with onComplete using SWF studio pro. It would work great in the flash ide, but after it’s on a cd rom as an exe or swf. onComplete would not fire for certain flv’s.
reencoding the flv would help most of the time, but this made me paranoid, so I made a deadlock timer, that I fed the total running time of the flv. If the timer went longer than the length it would check media.playing…
kind of a bronze age hack, but it made me feel better.
Found it! Thanks to my archive of ChattyFig emails on Gmail and a Robert Holloway, even if you supposedly obliterate the component with code you have to clear the media and cue points with code.
mdVideo.setMedia(“”, “FLV”);
mdVideo.removeAllCuePoints();
That worked. I’m not using cue points so maybe it would work without the removeAllCuePoints bit.
Yay!
Brent