All pastes #567155 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-06-14 20:11 UTC
rendered paste body
volumeBar_mc.visible = false;

var volVisibleCheck:Boolean = false;

var loader:URLLoader = new URLLoader();
loader.load(new URLRequest("video.xml"));
loader.addEventListener(Event.COMPLETE, XMLLoaded);

var timeGuideRect:Rectangle = new Rectangle(0,0,241.2-6.5,0);
var volGuideRect:Rectangle = new Rectangle(0,0,0,-65);

var sound:SoundTransform = new SoundTransform();

var stopPlay:Boolean = false;

var duration:int;

var mainInterval:int = setInterval(time,10);

var pauseBool:Boolean = false;

var dataHandler:Object = new Object();
dataHandler.onMetaData = metaInfo;

var netCon:NetConnection = new NetConnection();
netCon.connect(null);

var netStream:NetStream = new NetStream(netCon);
netStream.client = dataHandler;
function XMLLoaded(event:Event){
	var videoXML:XML = new XML(loader.data);
	videoXML.ignoreWhitespace = true;
	netStream.play("videos/" + String(videoXML.video[0].path));
}
netStream.soundTransform = sound;

video_mc.player_video.attachNetStream(netStream);

function metaInfo(sendBack:Object) {
	duration_txt.text = String(Math.floor(sendBack.duration / 60)) + ":" + String(Math.floor(sendBack.duration % 60));
	duration = sendBack.duration;
}
function fullScreen(event:MouseEvent) {
	stage.displayState = "fullScreen";
}
function normalScreen(event:FullScreenEvent) {
	if (stage.displayState == "normal") {
		video_mc.x = 9.1;
		video_mc.y = 9.0;
		video_mc.width = 459.1;
		video_mc.height = 252.0;
		volume_mc.visible = true;
	}
	if (stage.displayState == "fullScreen") {
		video_mc.x = 0;
		video_mc.y = 0;
		video_mc.width = 477;
		video_mc.height = 311;
		volume_mc.visible = false;
	}
}
function playBTN(event:MouseEvent) {
	if (pauseBool == false) {
		netStream.pause();
		pauseBool = true;
		play_mc.gotoAndStop(2);
	} else if (pauseBool == true) {
		netStream.resume();
		pauseBool = false;
		play_mc.gotoAndStop(1);
	}
}
function time() {
	if (Math.floor(netStream.time % 60) > 9) {
		time_txt.text = String(Math.floor(netStream.time / 60)) + ":" + String(Math.floor(netStream.time % 60));
	} else {
		time_txt.text = String(Math.floor(netStream.time / 60)) + ":0" + String(Math.floor(netStream.time % 60));
	}
	loadBar_mc.width = Math.round(netStream.bytesLoaded/netStream.bytesTotal*241.2);
	if (stopPlay == false) {
		guideBar_mc.seek_mc.x = Math.floor(netStream.time/duration * (241.2-6.5));
	}
}
function startD(event:MouseEvent) {
	stopPlay = true;
	guideBar_mc.seek_mc.startDrag(false,timeGuideRect);
	var seekInterval:int = setInterval(seekInt,10);
	function seekInt() {
		if (stopPlay == true) {
			netStream.seek(Math.floor(guideBar_mc.seek_mc.x/(241.2-6.5)*duration));
		}
	}
}
function stopD(event:MouseEvent) {
	if (stopPlay == true) {
		stopPlay = false;
		guideBar_mc.seek_mc.stopDrag();
		guideBar_mc.seek_mc.gotoAndPlay(11);
	}
	volumeBar_mc.volSlide_mc.stopDrag();
	volumeBar_mc.visible = false;
	volVisibleCheck = false;
}
function playSeek(event:MouseEvent) {
	if (stopPlay == false) {
		guideBar_mc.seek_mc.gotoAndPlay(2);
	}
}
function stopSeek(event:MouseEvent) {
	if (stopPlay == false) {
		guideBar_mc.seek_mc.gotoAndPlay(11);
	}
}
function volumeShow(event:MouseEvent) {
	if (volVisibleCheck == false) {
		volumeBar_mc.visible = true;
		volVisibleCheck = true;
		//trace(volVisibleCheck);
	} else if (volVisibleCheck == true) {
		volumeBar_mc.visible = false;
		volVisibleCheck = false;
	}
}
function volSlideStart(event:MouseEvent) {
	volumeBar_mc.volSlide_mc.startDrag(false,volGuideRect);
	var soundInterval:int = setInterval(volSet,10);
	function volSet() {
		sound.volume = volumeBar_mc.volSlide_mc.y/65;
		netStream.soundTransform = sound;
	}
}
fullScreen_mc.addEventListener(MouseEvent.CLICK, fullScreen);
stage.addEventListener(FullScreenEvent.FULL_SCREEN,normalScreen);
play_mc.addEventListener(MouseEvent.CLICK, playBTN);
guideBar_mc.seek_mc.addEventListener(MouseEvent.MOUSE_DOWN, startD);
guideBar_mc.seek_mc.addEventListener(MouseEvent.MOUSE_OVER, playSeek);
guideBar_mc.seek_mc.addEventListener(MouseEvent.MOUSE_OUT, stopSeek);
stage.addEventListener(MouseEvent.MOUSE_UP, stopD);
volume_mc.addEventListener(MouseEvent.CLICK, volumeShow);
volumeBar_mc.volSlide_mc.addEventListener(MouseEvent.MOUSE_DOWN, volSlideStart);