0
votes

Does anyone know how to add a custom 'Play' button to a .swf containing a .flv file. I have the following code that works perfectly (but its AS3) - I would like it to work with older flashplayers if possible:

import fl.video.VideoEvent;
import fl.video.VideoState;

video.addEventListener(VideoEvent.STATE_CHANGE,showButton);
playVideoButton.addEventListener(MouseEvent.MOUSE_UP,playVideo);

function playVideo(event:MouseEvent):void {
video.play();
playVideoButton.visible=false;
}

function showButton(event:VideoEvent):void {
switch (event.target.state) {
case "stopped" :
playVideoButton.visible=true;
break;
case "playing" :
playVideoButton.visible=false;
break;
case "paused" :
playVideoButton.visible=true;
break;
}
}

Also, is there a way of making sure the .flv has fully loaded before it plays, or do I have to use a container?

Thanks...

2

2 Answers

1
votes

Well if you just want that same type code but in AS2...

playButton.onPress = function()
{
    video.play();
}

And there are ways of checking how loaded / how many bytes remain of a swf.. I don't know them off the top of my head but it's the same code people use in actionscript 2.0 loading screens... If you just google "AS2 loading screen" you should find the code that will also work for checking if an embeded swf file is loaded all the way.

0
votes

Rather than messing with all of that code, flash has a built in function to create the player with the play button, buffer plist info and all that good stuff... I believe you go to (on a new project) file > import > import video > (select your .flv) > choose the player you want... Then set your stage size to fit contents.. You can load that flv player (copy and paste) into any other project file you have, so it will show it inside a .swf like you asked. You can even scale it and everything! Good luck!