I have a flash banner with a youtube video embeded within it. When the user presses a button, the banner goes to a specific frame and plays the video. What I need it to do, is after the video is finished, for it to forward to another frame.
The AS3 I am using to pull in the youtube video is below:
stop();
var player:Object;
Security.allowDomain("www.youtube.com");
var vidctn:Loader = new Loader();
vidctn.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
vidctn.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
function onLoaderInit(e:Event):void{
addChild(vidctn);
player = vidctn.content;
player.addEventListener("onReady", onPlayerReady);
}
function onPlayerReady(e:Event):void{
player.destroy();
addChildAt(vidctn,0);
player.setSize(304,173);
player.x = 0;
player.y = 40;
player.mute();
player.loadVideoById("Dzz6lUsF19g",0,"large");
}
I’m thinking I need an eventlistener, possibly Event.COMPLETE, but I can’t seem to come up with one.
these are the states of the youtube api (you only need YT_ENDED, but it is nice to have all):
add a listener:
and here is the function: