Flash AS3: (VideoEvent.COMPLETE, completePlay) - listener is triggered before video is completed

Tevi picture Tevi · Mar 18, 2010 · Viewed 24.6k times · Source

I have a flash video using the standard FLV Playback component that comes with Flash. I'm using ActionScript 3 to modify the appearance and set up an event listener. I've set it up to go to a new URL using "externalInterface" when the video completes play. The URL is set in a variable using SWFObject.

On only a few instances (3 people out of 50 - tested using Amazon Turk), people reported being taken directly to the new url, before the video even started playing. It's difficult to repeat the issue, but it did happen to me once. It doesn't have anything to do with cache, since it has been reported on people going to the url for the first time.

Here's the url to the video: http://www.partstown.com/is-bin/INTERSHOP.enfinity/WFS/Reedy-PartsTown-Site/en_US/-/USD/ViewStaticPage-UnFramed?page=tourthetown

Here's the code:

import flash.external.*;
import fl.video.*;
var myVideo:FLVPlayback = new FLVPlayback();

var theUrl:String = this.loaderInfo.parameters.urlName;
var theScript:String = this.loaderInfo.parameters.scriptName;


myVideo.source = this.loaderInfo.parameters.videoPath;//"partstown.flv";
myVideo.skin = this.loaderInfo.parameters.skinPath;//"SkinUnderPlayStopSeekMuteVol.swf"
myVideo.skinBackgroundColor = 0xAEBEFB;
myVideo.skinBackgroundAlpha = 0.5;
myVideo.width = 939;
myVideo.height = 660;


myVideo.addEventListener(VideoEvent.COMPLETE, completePlay);
function completePlay(e:VideoEvent):void {
 myVideo.alpha=0.2;
 ExternalInterface.call(theScript);
}


addChild(myVideo);

Why would the listener be triggered before the event complete? How can I fix it?

Thanks!

Answer

Justin Gregoire picture Justin Gregoire · Mar 18, 2010

from what I was ablr to find you would need to check to see the initial stopped state of the video.

This snippet will detect when the video has reached a "stopped" state. The "playbackBegun" boolean is used as a way to ignore the first "stopped" state, which occurs before the video begins it's "playing" state

the code is found here

dreamincode .

From what I understood is that after the video is loaded is has an initial stopped state, which means your fully loaded video triggers the event. thus the video is skipped. I had gone to the link you posted and found that I too was redirected before the video played.

hope this helps a bit. will keep looking to see if there is anything else.