Revision: 16026
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 23, 2009 12:35 by Winkyboy
Initial Code
// send this file the flashvars: "videofile" + optional "barcolor" + optional "autoplay=false" + optional "mute=true"
import fl.video.* // to be able to refer to the properties of the FLVPlayback component
var objFlashVars:Object = getFlashVars();
myVideo.autoPlay = true; // the FLVPlayback component instance on the stage is named myVideo
myVideo.source = "http://www.mediacollege.com/video-gallery/testclips/20051210-w50s_56K.flv"; // a default video. This will be over-ridden by your value from the FlashVars
myVideo.skin = getContextPath() + "SkinOverAllNoFullNoCaption.swf"; // feel free to change the skin. This will need to be placed in the same directory as the genplayer.swf
// Change settings based on FlashVars:
if (objFlashVars.videofile != undefined) { myVideo.source = objFlashVars.videofile; }
if (objFlashVars.barcolor != undefined) { myVideo.skinBackgroundColor = objFlashVars.barcolor; }
if (objFlashVars.autoplay != undefined) { if (objFlashVars.autoplay == "false") { myVideo.autoPlay = false; } }
if (objFlashVars.mute != undefined) { if (objFlashVars.mute == "true") { myVideo.volume = 0; } }
// Get rid of the loader:
myVideo.addEventListener(VideoEvent.READY, myFun);
function myFun(e:VideoEvent):void {
spinner_mc.stop();
spinner_mc.visible = false;
spinner_mc.enabled = false;
}
// That's it. The video should autoPlay unless you've told it not to with FlashVars.
////////////////////////////////////////////////////////////////////////////////////////////////
// Related Functions Below, from http://snipplr.com/view/10204/as3-my-favorite-helper-functions/
////////////////////////////////////////////////////////////////////////////////////////////////
function getFlashVars():Object
{
return Object( LoaderInfo( this.loaderInfo ).parameters );
}
function getContextPath():String
{
var uri:String = getLoaderURL();
return uri.substring(0, uri.lastIndexOf("/")) + "/";
}
function getLoaderURL():String
{
return this.loaderInfo.loaderURL;
}
Initial URL
http://files.getdropbox.com/u/316550/code-AS3_videoplayer.zip
Initial Description
An ActionScript3 video player placed on the stage, configurable by FlashVars. It displays a spinning loader until the video loads. Also see http://snipplr.com/view/11606/ for another AS3 video code template Read about AS3 video in this in-depth tutorial: http://www.republicofcode.com/tutorials/flash/as3flvplayback/
Initial Title
AS3 Video Player, placed on timeline, with spinning preloader
Initial Tags
video
Initial Language
ActionScript 3