How to use document classes correctly with ActionScript 3

Ricky-McM
Ricky-McM used Ask the Experts™
on
Hey there,

I have been having some trouble with setting up a flash player that I have been trying to adapt. the original code I am using here is from:
http://www.thetechlabs.com/tutorials/audionvideo/how-to-build-a-as3-videoplayer/

The code I have provided below is essentially exacly the same thing (with some extra comments and my own code commented out) but I have tried to remove the code from the flash file and put it into its own document class.
My reasoning for this (whether it is correct practice or otherwise?) is so that I can learn more about document classes and how they are used and also make the .as file reusable. By this I mean, I aim to have differing flash files with a different skin on buttons, colours, sizes etc and just reference the same doucment class.(?)

As you can see I am not 100% on my thinking about this. Any direction on what good actionscript books are available for beginners (I have a small background in java and C#) would also be helpful for the future, I am close to buying colin moocks essential actionscript 3.0

ANYWAY, the code in question is below and the errors I am getting say this:

1180: Call to a possibly undefined method initVideoPlayer.
1046: Type was not found or was not a compile-time constant: Timer.
1180: Call to a possibly undefined method Timer.
1180: Call to a possibly undefined method Rectangle.
1180: Call to a possibly undefined method Rectangle.
1180: Call to a possibly undefined method SoundTransform.

I have so many thoughts in my head its hard to pluck them out and explain (and research solutions) so I have came here. Hope someone will understand my rambling and hopefully point me in a clear direction that I understand. Cheers

// Code taken from -
// http://www.thetechlabs.com/tutorials/audionvideo/how-to-build-a-as3-videoplayer/
 
package{
	
	import flash.display.*;
	import flash.net.*;
	import flash.media.Video;
	import flash.events.*;
	
	
	public class PlayerScript extends Sprite{
	
 
		// ##########################
		// ################ CONSTANTS
		// ##########################
 
		// time to buffer for the video in sec.
		const BUFFER_TIME:Number				= 8;
		// start volume when initializing player
		const DEFAULT_VOLUME:Number				= 0.6;
		// update delay in milliseconds.
		const DISPLAY_TIMER_UPDATE_DELAY:int	= 10;
		// smoothing for video. may slow down old computers
		const SMOOTHING:Boolean					= true;
		
		// ##########################
		// ################ VARIABLES
		// ##########################
		
		// flag for knowing if flv has been loaded
		public var bolLoaded:Boolean					= false;
		// flag for volume scrubbing
		public var bolVolumeScrub:Boolean				= false;
		// flag for progress scrubbing
		public var bolProgressScrub:Boolean				= false;
		// holds the last used volume, but never 0
		public var intLastVolume:Number					= DEFAULT_VOLUME;
		// a net connection object for net stream and of course also a net stream object
		public var ncConnection:NetConnection;
		public var nsStream:NetStream;
		// object to store all the meta data received from the flv file
		public var objInfo:Object;
		// URLRequest to the ASP page where the strSource is defined
		// var strSource:String = root.loaderInfo.parameters.SWFFilename;
		// url to flv file
		public var strSource:String						= "hancockTrailer.flv";
		// timer for updating player (progress, volume...)
		public var tmrDisplay:Timer;
		
		
		
		// ##########################
		// ################ FUNCTIONS
		// ##########################
		
		// initialises the player on the page.
		// SOME CAPITALS USED BELOW REFERENCE THE CONSTANTS ABOVE!!! 
		function initVideoPlayer():void {
			// hide buttons
			mcVideoControls.btnUnmute.visible	= false;
			mcVideoControls.btnPause.visible	= false;
			
			// set the progress/preload fill width to 1
			mcVideoControls.mcProgressFill.mcFillRed.width = 1;
			mcVideoControls.mcProgressFill.mcFillGrey.width = 1;
			
			// add global event listener when mouse is released
			stage.addEventListener( MouseEvent.MOUSE_UP, mouseReleased);
			
			// add event listeners to all buttons
			mcVideoControls.btnPause.addEventListener(MouseEvent.CLICK, pauseClicked);
			mcVideoControls.btnPlay.addEventListener(MouseEvent.CLICK, playClicked);
			mcVideoControls.btnStop.addEventListener(MouseEvent.CLICK, stopClicked);
			mcVideoControls.btnMute.addEventListener(MouseEvent.CLICK, muteClicked);
			mcVideoControls.btnUnmute.addEventListener(MouseEvent.CLICK, unmuteClicked);
			mcVideoControls.mcVolumeScrubber.btnVolumeScrubber.addEventListener(MouseEvent.MOUSE_DOWN, volumeScrubberClicked);
			mcVideoControls.mcProgressScrubber.btnProgressScrubber.addEventListener(MouseEvent.MOUSE_DOWN, progressScrubberClicked);
			
			// create timer for updating all visual parts of player and add
			// event listener
			tmrDisplay = new Timer(DISPLAY_TIMER_UPDATE_DELAY);
			tmrDisplay.addEventListener(TimerEvent.TIMER, updateDisplay);
			
			// create a new net connection, add event listener and connect
			// to null because we don't have a media server
			ncConnection = new NetConnection();
			ncConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
			ncConnection.connect(null);
			
			// create a new stream with the net connection, add event
			// listener, set client to this for handling meta data and
			// set the buffer time to the value from the constant
			nsStream = new NetStream(ncConnection);
			nsStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
			nsStream.client = this;
			nsStream.bufferTime = BUFFER_TIME;
			
			// attach net stream to video object on the stage
			vidDisplay.attachNetStream(nsStream);
			// set the smoothing value from the constant
			vidDisplay.smoothing = SMOOTHING;
		
			// set default volume
			mcVideoControls.mcVolumeScrubber.x = (52 * DEFAULT_VOLUME) + 341;
			mcVideoControls.mcVolumeFill.mcFillRed.width = mcVideoControls.mcVolumeScrubber.x - 394 + 52;
			setVolume(DEFAULT_VOLUME);
		}
		
		function playClicked(e:MouseEvent):void {
			// check's if the flv has already begun
			// to download. if so, resume playback, else
			// load the file (strSource) <-- defined above in variables
			if(!bolLoaded) {
				nsStream.play(strSource);
				bolLoaded = true;
			}
			else{
				nsStream.resume();
			}
			
			// show video display
			vidDisplay.visible					= true;
			
			// switch play/pause visibility
			mcVideoControls.btnPause.visible	= true;
			mcVideoControls.btnPlay.visible		= false;
		}
		
		function pauseClicked(e:MouseEvent):void {
			// pause video
			nsStream.pause();
			
			// switch play/pause visibility
			mcVideoControls.btnPause.visible	= false;
			mcVideoControls.btnPlay.visible		= true;
		}
		
		function stopClicked(e:MouseEvent):void {
			// calls stop function
			stopVideoPlayer();
		}
		
		function muteClicked(e:MouseEvent):void {
			// set volume to 0
			setVolume(0);
			
			// update scrubber and fill position/width
			mcVideoControls.mcVolumeScrubber.x				= 341;
			mcVideoControls.mcVolumeFill.mcFillRed.width	= 1;
		}
		
		function unmuteClicked(e:MouseEvent):void {
			// set volume to last used value
			setVolume(intLastVolume);
		
			// update scrubber and fill position/width
			mcVideoControls.mcVolumeScrubber.x = (53 * intLastVolume) + 341;
			mcVideoControls.mcVolumeFill.mcFillRed.width = mcVideoControls.mcVolumeScrubber.x - 394 + 53;
		}
		
		function volumeScrubberClicked(e:MouseEvent):void {
			// set volume scrub flag to true
			bolVolumeScrub = true;
			
			// start drag
			mcVideoControls.mcVolumeScrubber.startDrag(false, new Rectangle(341, 19, 53, 0));
		}
		
		function progressScrubberClicked(e:MouseEvent):void {
			// set progress scrub flag to true
			bolProgressScrub = true;
			
			// start drag
			mcVideoControls.mcProgressScrubber.startDrag(false, new Rectangle(0, 2, 432, 0));
		}
		
		function mouseReleased(e:MouseEvent):void {
			// set progress/volume scrub to false
			bolVolumeScrub		= false;
			bolProgressScrub	= false;
			
			// stop all dragging actions
			mcVideoControls.mcProgressScrubber.stopDrag();
			mcVideoControls.mcVolumeScrubber.stopDrag();
			
			// update progress/volume fill
			mcVideoControls.mcProgressFill.mcFillRed.width	= mcVideoControls.mcProgressScrubber.x + 5;
			mcVideoControls.mcVolumeFill.mcFillRed.width	= mcVideoControls.mcVolumeScrubber.x - 394 + 53;
			
			// save the volume if it's greater than zero
			if((mcVideoControls.mcVolumeScrubber.x - 341) / 53 > 0)
				intLastVolume = (mcVideoControls.mcVolumeScrubber.x - 341) / 53;
		}
		
		function updateDisplay(e:TimerEvent):void {
			// checks, if user is scrubbing. if so, seek in the video
			// if not, just update the position of the scrubber according
			// to the current time
			if(bolProgressScrub)
				nsStream.seek(Math.round(mcVideoControls.mcProgressScrubber.x * objInfo.duration / 432))
			else
				mcVideoControls.mcProgressScrubber.x = nsStream.time * 432 / objInfo.duration; 
			
			// set time and duration label
			mcVideoControls.lblTimeDuration.htmlText		= "<font color='#ffffff'>" + formatTime(nsStream.time) + "</font> / " + formatTime(objInfo.duration);
			
			// update the width from the progress bar. the grey one displays
			// the loading progress
			mcVideoControls.mcProgressFill.mcFillRed.width	= mcVideoControls.mcProgressScrubber.x + 5;
			mcVideoControls.mcProgressFill.mcFillGrey.width	= nsStream.bytesLoaded * 438 / nsStream.bytesTotal;
			
			// update volume and the red fill width when user is scrubbing
			if(bolVolumeScrub) {
				setVolume((mcVideoControls.mcVolumeScrubber.x - 341) / 53);
				mcVideoControls.mcVolumeFill.mcFillRed.width = mcVideoControls.mcVolumeScrubber.x - 394 + 53;
			}
		}
		
		function onMetaData(info:Object):void {
			// stores meta data in a object
			objInfo = info;
			
			// now we can start the timer because
			// we have all the neccesary data
			tmrDisplay.start();
		}
		
		function netStatusHandler(event:NetStatusEvent):void {
			// handles net status events
			switch (event.info.code) {
				// trace a messeage when the stream is not found
				case "NetStream.Play.StreamNotFound":
					trace("Stream not found: " + strSource);
				break;
				
				// when the video reaches its end, we stop the player
				case "NetStream.Play.Stop":
					stopVideoPlayer();
				break;
			}
		}
		
		// for when the stop button is clicked
		function stopVideoPlayer():void {
			// pause netstream, set time position to zero
			nsStream.pause();
			nsStream.seek(0);
			
			// in order to clear the display, we need to
			// set the visibility to false since the clear
			// function has a bug
			vidDisplay.visible					= false;
			
			// switch play/pause button visibility
			mcVideoControls.btnPause.visible	= false;
			mcVideoControls.btnPlay.visible		= true;
		}
		
		function setVolume(intVolume:Number = 0):void {
			// create soundtransform object with the volume from
			// the parameter
			var sndTransform		= new SoundTransform(intVolume);
			// assign object to netstream sound transform object
			nsStream.soundTransform	= sndTransform;
			
			// hides/shows mute and unmute button according to the
			// volume
			if(intVolume > 0) {
				mcVideoControls.btnMute.visible		= true;
				mcVideoControls.btnUnmute.visible	= false;
			} else {
				mcVideoControls.btnMute.visible		= false;
				mcVideoControls.btnUnmute.visible	= true;
			}
		}
		
		function formatTime(t:int):String {
			// returns the minutes and seconds with leading zeros
			// for example: 70 returns 01:10
			var s:int = Math.round(t);
			var m:int = 0;
			if (s > 0) {
				while (s > 59) {
					m++;
					s -= 60;
				}
				return String((m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s);
			} else {
				return "00:00";
			}
		}
		
		// ##########################
		// ######## INITIALISE PLAYER
		// ##########################
 
		initVideoPlayer();
	
	}//end Public Class PlayerScript
		
}//end Package
		
// to AUTOMATICALLY PLAY the file un comment the code below
// playClicked(null);

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2009
Commented:
I am not sure how to fix your first error but it will probably go away after adding this three lines of import code under other import code

import flash.utils.Timer;
import flash.geom.Rectangle;
import flash.media.SoundTransform;

Please tell me with the new code what errors do you get?

Top Expert 2009

Commented:
BTW yes essential actionscript 3.0 is good but for you I think you should purchase beginner's guide to actionscript 3.0 too, read that up first and essential actionscript 3.0 will always be good as a reference book. Adobe's documentation is really good too if you do not want to buy any books.

Author

Commented:
The other errors have gone yes but I am still left with one

1180: Call to a possibly undefined method initVideoPlayer.

It is very frustrating, i knew that i was missing certain import classes but where do you look to find what ones to use!!!!? I could'nt find anything, annoying especially when I sort of knew a part of what was going wrong.
1180: Call to a possibly undefined method initVideoPlayer.

Open in new window

Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Top Expert 2009
Commented:
Mostly through experience, you will remember the classes as you use them. However, if you happen to forget, check out adobe's documentation and it will write where classes belong.

The error happens because  you can't call an instance method of a class, you have to read up the basics first. To fix this error, you simply place all of the code in initVideoPlayer in the constructor method of PlayerScript, thus removing the need for calling a function.

See code snippet for edited code.

// Code taken from -
// http://www.thetechlabs.com/tutorials/audionvideo/how-to-build-a-as3-videoplayer/
 
package{
	
	import flash.display.*;
	import flash.net.*;
	import flash.media.Video;
	import flash.events.*;
 
	import flash.utils.Timer;
	import flash.geom.Rectangle;
	import flash.media.SoundTransform;
	
	
	public class PlayerScript extends Sprite{
	
 
		// ##########################
		// ################ CONSTANTS
		// ##########################
 
		// time to buffer for the video in sec.
		const BUFFER_TIME:Number				= 8;
		// start volume when initializing player
		const DEFAULT_VOLUME:Number				= 0.6;
		// update delay in milliseconds.
		const DISPLAY_TIMER_UPDATE_DELAY:int	= 10;
		// smoothing for video. may slow down old computers
		const SMOOTHING:Boolean					= true;
		
		// ##########################
		// ################ VARIABLES
		// ##########################
		
		// flag for knowing if flv has been loaded
		public var bolLoaded:Boolean					= false;
		// flag for volume scrubbing
		public var bolVolumeScrub:Boolean				= false;
		// flag for progress scrubbing
		public var bolProgressScrub:Boolean				= false;
		// holds the last used volume, but never 0
		public var intLastVolume:Number					= DEFAULT_VOLUME;
		// a net connection object for net stream and of course also a net stream object
		public var ncConnection:NetConnection;
		public var nsStream:NetStream;
		// object to store all the meta data received from the flv file
		public var objInfo:Object;
		// URLRequest to the ASP page where the strSource is defined
		// var strSource:String = root.loaderInfo.parameters.SWFFilename;
		// url to flv file
		public var strSource:String						= "hancockTrailer.flv";
		// timer for updating player (progress, volume...)
		public var tmrDisplay:Timer;
		
		
		
		// ##########################
		// ################ FUNCTIONS
		// ##########################
		
		// initialises the player on the page.
		// SOME CAPITALS USED BELOW REFERENCE THE CONSTANTS ABOVE!!! 
		public function PlayerScript():void {
			// hide buttons
			mcVideoControls.btnUnmute.visible	= false;
			mcVideoControls.btnPause.visible	= false;
			
			// set the progress/preload fill width to 1
			mcVideoControls.mcProgressFill.mcFillRed.width = 1;
			mcVideoControls.mcProgressFill.mcFillGrey.width = 1;
			
			// add global event listener when mouse is released
			stage.addEventListener( MouseEvent.MOUSE_UP, mouseReleased);
			
			// add event listeners to all buttons
			mcVideoControls.btnPause.addEventListener(MouseEvent.CLICK, pauseClicked);
			mcVideoControls.btnPlay.addEventListener(MouseEvent.CLICK, playClicked);
			mcVideoControls.btnStop.addEventListener(MouseEvent.CLICK, stopClicked);
			mcVideoControls.btnMute.addEventListener(MouseEvent.CLICK, muteClicked);
			mcVideoControls.btnUnmute.addEventListener(MouseEvent.CLICK, unmuteClicked);
			mcVideoControls.mcVolumeScrubber.btnVolumeScrubber.addEventListener(MouseEvent.MOUSE_DOWN, volumeScrubberClicked);
			mcVideoControls.mcProgressScrubber.btnProgressScrubber.addEventListener(MouseEvent.MOUSE_DOWN, progressScrubberClicked);
			
			// create timer for updating all visual parts of player and add
			// event listener
			tmrDisplay = new Timer(DISPLAY_TIMER_UPDATE_DELAY);
			tmrDisplay.addEventListener(TimerEvent.TIMER, updateDisplay);
			
			// create a new net connection, add event listener and connect
			// to null because we don't have a media server
			ncConnection = new NetConnection();
			ncConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
			ncConnection.connect(null);
			
			// create a new stream with the net connection, add event
			// listener, set client to this for handling meta data and
			// set the buffer time to the value from the constant
			nsStream = new NetStream(ncConnection);
			nsStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
			nsStream.client = this;
			nsStream.bufferTime = BUFFER_TIME;
			
			// attach net stream to video object on the stage
			vidDisplay.attachNetStream(nsStream);
			// set the smoothing value from the constant
			vidDisplay.smoothing = SMOOTHING;
		
			// set default volume
			mcVideoControls.mcVolumeScrubber.x = (52 * DEFAULT_VOLUME) + 341;
			mcVideoControls.mcVolumeFill.mcFillRed.width = mcVideoControls.mcVolumeScrubber.x - 394 + 52;
			setVolume(DEFAULT_VOLUME);
		}
		
		function playClicked(e:MouseEvent):void {
			// check's if the flv has already begun
			// to download. if so, resume playback, else
			// load the file (strSource) <-- defined above in variables
			if(!bolLoaded) {
				nsStream.play(strSource);
				bolLoaded = true;
			}
			else{
				nsStream.resume();
			}
			
			// show video display
			vidDisplay.visible					= true;
			
			// switch play/pause visibility
			mcVideoControls.btnPause.visible	= true;
			mcVideoControls.btnPlay.visible		= false;
		}
		
		function pauseClicked(e:MouseEvent):void {
			// pause video
			nsStream.pause();
			
			// switch play/pause visibility
			mcVideoControls.btnPause.visible	= false;
			mcVideoControls.btnPlay.visible		= true;
		}
		
		function stopClicked(e:MouseEvent):void {
			// calls stop function
			stopVideoPlayer();
		}
		
		function muteClicked(e:MouseEvent):void {
			// set volume to 0
			setVolume(0);
			
			// update scrubber and fill position/width
			mcVideoControls.mcVolumeScrubber.x				= 341;
			mcVideoControls.mcVolumeFill.mcFillRed.width	= 1;
		}
		
		function unmuteClicked(e:MouseEvent):void {
			// set volume to last used value
			setVolume(intLastVolume);
		
			// update scrubber and fill position/width
			mcVideoControls.mcVolumeScrubber.x = (53 * intLastVolume) + 341;
			mcVideoControls.mcVolumeFill.mcFillRed.width = mcVideoControls.mcVolumeScrubber.x - 394 + 53;
		}
		
		function volumeScrubberClicked(e:MouseEvent):void {
			// set volume scrub flag to true
			bolVolumeScrub = true;
			
			// start drag
			mcVideoControls.mcVolumeScrubber.startDrag(false, new Rectangle(341, 19, 53, 0));
		}
		
		function progressScrubberClicked(e:MouseEvent):void {
			// set progress scrub flag to true
			bolProgressScrub = true;
			
			// start drag
			mcVideoControls.mcProgressScrubber.startDrag(false, new Rectangle(0, 2, 432, 0));
		}
		
		function mouseReleased(e:MouseEvent):void {
			// set progress/volume scrub to false
			bolVolumeScrub		= false;
			bolProgressScrub	= false;
			
			// stop all dragging actions
			mcVideoControls.mcProgressScrubber.stopDrag();
			mcVideoControls.mcVolumeScrubber.stopDrag();
			
			// update progress/volume fill
			mcVideoControls.mcProgressFill.mcFillRed.width	= mcVideoControls.mcProgressScrubber.x + 5;
			mcVideoControls.mcVolumeFill.mcFillRed.width	= mcVideoControls.mcVolumeScrubber.x - 394 + 53;
			
			// save the volume if it's greater than zero
			if((mcVideoControls.mcVolumeScrubber.x - 341) / 53 > 0)
				intLastVolume = (mcVideoControls.mcVolumeScrubber.x - 341) / 53;
		}
		
		function updateDisplay(e:TimerEvent):void {
			// checks, if user is scrubbing. if so, seek in the video
			// if not, just update the position of the scrubber according
			// to the current time
			if(bolProgressScrub)
				nsStream.seek(Math.round(mcVideoControls.mcProgressScrubber.x * objInfo.duration / 432))
			else
				mcVideoControls.mcProgressScrubber.x = nsStream.time * 432 / objInfo.duration; 
			
			// set time and duration label
			mcVideoControls.lblTimeDuration.htmlText		= "<font color='#ffffff'>" + formatTime(nsStream.time) + "</font> / " + formatTime(objInfo.duration);
			
			// update the width from the progress bar. the grey one displays
			// the loading progress
			mcVideoControls.mcProgressFill.mcFillRed.width	= mcVideoControls.mcProgressScrubber.x + 5;
			mcVideoControls.mcProgressFill.mcFillGrey.width	= nsStream.bytesLoaded * 438 / nsStream.bytesTotal;
			
			// update volume and the red fill width when user is scrubbing
			if(bolVolumeScrub) {
				setVolume((mcVideoControls.mcVolumeScrubber.x - 341) / 53);
				mcVideoControls.mcVolumeFill.mcFillRed.width = mcVideoControls.mcVolumeScrubber.x - 394 + 53;
			}
		}
		
		function onMetaData(info:Object):void {
			// stores meta data in a object
			objInfo = info;
			
			// now we can start the timer because
			// we have all the neccesary data
			tmrDisplay.start();
		}
		
		function netStatusHandler(event:NetStatusEvent):void {
			// handles net status events
			switch (event.info.code) {
				// trace a messeage when the stream is not found
				case "NetStream.Play.StreamNotFound":
					trace("Stream not found: " + strSource);
				break;
				
				// when the video reaches its end, we stop the player
				case "NetStream.Play.Stop":
					stopVideoPlayer();
				break;
			}
		}
		
		// for when the stop button is clicked
		function stopVideoPlayer():void {
			// pause netstream, set time position to zero
			nsStream.pause();
			nsStream.seek(0);
			
			// in order to clear the display, we need to
			// set the visibility to false since the clear
			// function has a bug
			vidDisplay.visible					= false;
			
			// switch play/pause button visibility
			mcVideoControls.btnPause.visible	= false;
			mcVideoControls.btnPlay.visible		= true;
		}
		
		function setVolume(intVolume:Number = 0):void {
			// create soundtransform object with the volume from
			// the parameter
			var sndTransform		= new SoundTransform(intVolume);
			// assign object to netstream sound transform object
			nsStream.soundTransform	= sndTransform;
			
			// hides/shows mute and unmute button according to the
			// volume
			if(intVolume > 0) {
				mcVideoControls.btnMute.visible		= true;
				mcVideoControls.btnUnmute.visible	= false;
			} else {
				mcVideoControls.btnMute.visible		= false;
				mcVideoControls.btnUnmute.visible	= true;
			}
		}
		
		function formatTime(t:int):String {
			// returns the minutes and seconds with leading zeros
			// for example: 70 returns 01:10
			var s:int = Math.round(t);
			var m:int = 0;
			if (s > 0) {
				while (s > 59) {
					m++;
					s -= 60;
				}
				return String((m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s);
			} else {
				return "00:00";
			}
		}
	
	}//end Public Class PlayerScript
		
}//end Package
		
// to AUTOMATICALLY PLAY the file un comment the code below
// playClicked(null);

Open in new window

Author

Commented:
See below. I thought that would be an easier way to understand. Thanks very much for your time.
After using the amended code I received this in the 'output' panel.
 
Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetStream was unable to invoke callback onMetaData. error=ReferenceError: Error #1069: Property onMetaData not found on PlayerScript and there is no default value.
	at PlayerScript$iinit()
 
Found this info on how to handle the AsynceErrorEvent
http://www.adobe.com/devnet/flash/quickstart/metadata_cue_points/
Implemented the first solution.
 
Still left with this in the 'ouput' panel
 
Error #2095: flash.net.NetStream was unable to invoke callback onMetaData.

Open in new window

Top Expert 2009

Commented:
you can alternatively call initVideoPlayer inside the constructor rather than putting all the code there.


            public function PlayerScript()
            {
                  initVideoPlayer();
            }
            

Author

Commented:
Thanks for that alternative idea, I have got that working however still working on the other error explained above.

Am i correct in saying if i 'handle' the error it wont make any difference to how the player performs? it just wont' show me the error. I have to get some tea and will work on this later, thank you for replies but could still need some guidence. (sory for rushed response)
Top Expert 2009

Commented:
where's the function in the code at PlayerScript$iinit()
 that's throwing the error?
Top Expert 2009

Commented:
No error messages should appear after you handled the errors, can you please post the full source so I can test?

Author

Commented:
This is all the code as it stands now. It does not show anything in the 'compiler errors' panel. In the 'output panel it shows this:
Error #2095: flash.net.NetStream was unable to invoke callback onMetaData.

I hav'nt handled that problem yet still working on it.

I don't know what you need to know but it uses the meta data to allow the scrubber and timer to work correctly. At the momen the video is playing fine just the scrubber does not moved form the start position when playing and the timer does not show up at all.
// Code taken from -
// http://www.thetechlabs.com/tutorials/audionvideo/how-to-build-a-as3-videoplayer/
 
package{
	
	import flash.display.*;
	import flash.net.*;
	import flash.media.Video;
	import flash.events.*;
 
	import flash.utils.Timer;
	import flash.geom.Rectangle;
	import flash.media.SoundTransform;
	
	
	public class PlayerScript extends Sprite{
	
 
		// ##########################
		// ################ CONSTANTS
		// ##########################
 
		// time to buffer for the video in sec.
		const BUFFER_TIME:Number				= 8;
		// start volume when initializing player
		const DEFAULT_VOLUME:Number				= 0.6;
		// update delay in milliseconds.
		const DISPLAY_TIMER_UPDATE_DELAY:int	= 10;
		// smoothing for video. may slow down old computers
		const SMOOTHING:Boolean					= true;
		
		// ##########################
		// ################ VARIABLES
		// ##########################
		
		// flag for knowing if flv has been loaded
		public var bolLoaded:Boolean					= false;
		// flag for volume scrubbing
		public var bolVolumeScrub:Boolean				= false;
		// flag for progress scrubbing
		public var bolProgressScrub:Boolean				= false;
		// holds the last used volume, but never 0
		public var intLastVolume:Number					= DEFAULT_VOLUME;
		// a net connection object for net stream and of course also a net stream object
		public var ncConnection:NetConnection;
		public var nsStream:NetStream;
		// object to store all the meta data received from the flv file
		public var objInfo:Object;
		// URLRequest to the ASP page where the strSource is defined
		// var strSource:String = root.loaderInfo.parameters.SWFFilename;
		// url to flv file
		public var strSource:String						= "hancockTrailer.flv";
		// timer for updating player (progress, volume...)
		public var tmrDisplay:Timer;
				
		// ##########################
		// ################ FUNCTIONS
		// ##########################
		
		// initialises the player on the page.
		// SOME CAPITALS USED BELOW REFERENCE THE CONSTANTS ABOVE!!! 
		public function initVideoPlayer():void {
			// hide buttons
			mcVideoControls.btnUnmute.visible	= false;
			mcVideoControls.btnPause.visible	= false;
			
			// set the progress/preload fill width to 1
			mcVideoControls.mcProgressFill.mcFillRed.width = 1;
			mcVideoControls.mcProgressFill.mcFillGrey.width = 1;
			
			// add global event listener when mouse is released
			stage.addEventListener( MouseEvent.MOUSE_UP, mouseReleased);
			
			// add event listeners to all buttons
			mcVideoControls.btnPause.addEventListener(MouseEvent.CLICK, pauseClicked);
			mcVideoControls.btnPlay.addEventListener(MouseEvent.CLICK, playClicked);
			mcVideoControls.btnStop.addEventListener(MouseEvent.CLICK, stopClicked);
			mcVideoControls.btnMute.addEventListener(MouseEvent.CLICK, muteClicked);
			mcVideoControls.btnUnmute.addEventListener(MouseEvent.CLICK, unmuteClicked);
			mcVideoControls.mcVolumeScrubber.btnVolumeScrubber.addEventListener(MouseEvent.MOUSE_DOWN, volumeScrubberClicked);
			mcVideoControls.mcProgressScrubber.btnProgressScrubber.addEventListener(MouseEvent.MOUSE_DOWN, progressScrubberClicked);
			
			// create timer for updating all visual parts of player and add
			// event listener
			tmrDisplay = new Timer(DISPLAY_TIMER_UPDATE_DELAY);
			tmrDisplay.addEventListener(TimerEvent.TIMER, updateDisplay);
			
			// create a new net connection, add event listener and connect
			// to null because we don't have a media server
			ncConnection = new NetConnection();
			ncConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
			ncConnection.connect(null);
			
			// create a new stream with the net connection, add event
			// listener, set client to this for handling meta data and
			// set the buffer time to the value from the constant
			nsStream = new NetStream(ncConnection);
			nsStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
			nsStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
			nsStream.client = this;
			nsStream.bufferTime = BUFFER_TIME;
			
			// attach net stream to video object on the stage
			vidDisplay.attachNetStream(nsStream);
			// set the smoothing value from the constant
			vidDisplay.smoothing = SMOOTHING;
		
			// set default volume
			mcVideoControls.mcVolumeScrubber.x = (52 * DEFAULT_VOLUME) + 341;
			mcVideoControls.mcVolumeFill.mcFillRed.width = mcVideoControls.mcVolumeScrubber.x - 394 + 52;
			setVolume(DEFAULT_VOLUME);
		}
		
		function asyncErrorHandler(event:AsyncErrorEvent):void {
			trace(event.text);
		}
		
		
		function playClicked(e:MouseEvent):void {
			// check's if the flv has already begun
			// to download. if so, resume playback, else
			// load the file (strSource) <-- defined above in variables
			if(!bolLoaded) {
				nsStream.play(strSource);
				bolLoaded = true;
			}
			else{
				nsStream.resume();
			}
			
			// show video display
			vidDisplay.visible					= true;
			
			// switch play/pause visibility
			mcVideoControls.btnPause.visible	= true;
			mcVideoControls.btnPlay.visible		= false;
		}
		
		function pauseClicked(e:MouseEvent):void {
			// pause video
			nsStream.pause();
			
			// switch play/pause visibility
			mcVideoControls.btnPause.visible	= false;
			mcVideoControls.btnPlay.visible		= true;
		}
		
		function stopClicked(e:MouseEvent):void {
			// calls stop function
			stopVideoPlayer();
		}
		
		function muteClicked(e:MouseEvent):void {
			// set volume to 0
			setVolume(0);
			
			// update scrubber and fill position/width
			mcVideoControls.mcVolumeScrubber.x				= 341;
			mcVideoControls.mcVolumeFill.mcFillRed.width	= 1;
		}
		
		function unmuteClicked(e:MouseEvent):void {
			// set volume to last used value
			setVolume(intLastVolume);
		
			// update scrubber and fill position/width
			mcVideoControls.mcVolumeScrubber.x = (53 * intLastVolume) + 341;
			mcVideoControls.mcVolumeFill.mcFillRed.width = mcVideoControls.mcVolumeScrubber.x - 394 + 53;
		}
		
		function volumeScrubberClicked(e:MouseEvent):void {
			// set volume scrub flag to true
			bolVolumeScrub = true;
			
			// start drag
			mcVideoControls.mcVolumeScrubber.startDrag(false, new Rectangle(341, 19, 53, 0));
		}
		
		function progressScrubberClicked(e:MouseEvent):void {
			// set progress scrub flag to true
			bolProgressScrub = true;
			
			// start drag
			mcVideoControls.mcProgressScrubber.startDrag(false, new Rectangle(0, 2, 432, 0));
		}
		
		function mouseReleased(e:MouseEvent):void {
			// set progress/volume scrub to false
			bolVolumeScrub		= false;
			bolProgressScrub	= false;
			
			// stop all dragging actions
			mcVideoControls.mcProgressScrubber.stopDrag();
			mcVideoControls.mcVolumeScrubber.stopDrag();
			
			// update progress/volume fill
			mcVideoControls.mcProgressFill.mcFillRed.width	= mcVideoControls.mcProgressScrubber.x + 5;
			mcVideoControls.mcVolumeFill.mcFillRed.width	= mcVideoControls.mcVolumeScrubber.x - 394 + 53;
			
			// save the volume if it's greater than zero
			if((mcVideoControls.mcVolumeScrubber.x - 341) / 53 > 0)
				intLastVolume = (mcVideoControls.mcVolumeScrubber.x - 341) / 53;
		}
		
		function updateDisplay(e:TimerEvent):void {
			// checks, if user is scrubbing. if so, seek in the video
			// if not, just update the position of the scrubber according
			// to the current time
			if(bolProgressScrub)
				nsStream.seek(Math.round(mcVideoControls.mcProgressScrubber.x * objInfo.duration / 432))
			else
				mcVideoControls.mcProgressScrubber.x = nsStream.time * 432 / objInfo.duration; 
			
			// set time and duration label
			mcVideoControls.lblTimeDuration.htmlText		= "<font color='#ffffff'>" + formatTime(nsStream.time) + "</font> / " + formatTime(objInfo.duration);
			
			// update the width from the progress bar. the grey one displays
			// the loading progress
			mcVideoControls.mcProgressFill.mcFillRed.width	= mcVideoControls.mcProgressScrubber.x + 5;
			mcVideoControls.mcProgressFill.mcFillGrey.width	= nsStream.bytesLoaded * 438 / nsStream.bytesTotal;
			
			// update volume and the red fill width when user is scrubbing
			if(bolVolumeScrub) {
				setVolume((mcVideoControls.mcVolumeScrubber.x - 341) / 53);
				mcVideoControls.mcVolumeFill.mcFillRed.width = mcVideoControls.mcVolumeScrubber.x - 394 + 53;
			}
		}
		
		function onMetaData(info:Object):void {
			// stores meta data in a object
			objInfo = info;
			
			// now we can start the timer because
			// we have all the neccesary data
			tmrDisplay.start();
		}
		
		function netStatusHandler(event:NetStatusEvent):void {
			// handles net status events
			switch (event.info.code) {
				// trace a messeage when the stream is not found
				case "NetStream.Play.StreamNotFound":
					trace("Stream not found: " + strSource);
				break;
				
				// when the video reaches its end, we stop the player
				case "NetStream.Play.Stop":
					stopVideoPlayer();
				break;
			}
		}
		
		// for when the stop button is clicked
		function stopVideoPlayer():void {
			// pause netstream, set time position to zero
			nsStream.pause();
			nsStream.seek(0);
			
			// in order to clear the display, we need to
			// set the visibility to false since the clear
			// function has a bug
			vidDisplay.visible					= false;
			
			// switch play/pause button visibility
			mcVideoControls.btnPause.visible	= false;
			mcVideoControls.btnPlay.visible		= true;
		}
		
		function setVolume(intVolume:Number = 0):void {
			// create soundtransform object with the volume from
			// the parameter
			var sndTransform		= new SoundTransform(intVolume);
			// assign object to netstream sound transform object
			nsStream.soundTransform	= sndTransform;
			
			// hides/shows mute and unmute button according to the
			// volume
			if(intVolume > 0) {
				mcVideoControls.btnMute.visible		= true;
				mcVideoControls.btnUnmute.visible	= false;
			} else {
				mcVideoControls.btnMute.visible		= false;
				mcVideoControls.btnUnmute.visible	= true;
			}
		}
		
		function formatTime(t:int):String {
			// returns the minutes and seconds with leading zeros
			// for example: 70 returns 01:10
			var s:int = Math.round(t);
			var m:int = 0;
			if (s > 0) {
				while (s > 59) {
					m++;
					s -= 60;
				}
				return String((m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s);
			} else {
				return "00:00";
			}
		}
	
		public function PlayerScript(){
			initVideoPlayer();
        }
		
	}//end Public Class PlayerScript
		
}//end Package
		
// to AUTOMATICALLY PLAY the file un comment the code below
// playClicked(null);

Open in new window

Top Expert 2009

Commented:
Yes this is a runtime error, what I meant is that I need the full source so I can test out what problem it is myself.

Author

Commented:
These are the actionscript and flash files.
http://www.savefile.com/files/2159302

The movie used can be found in the source files of this project.
http://www.thetechlabs.com/tutorials/audionvideo/how-to-build-a-as3-videoplayer/
Top Expert 2009

Commented:
i'm going to leave this in the hands of TanLiHao and stop interfering.
good luck.
Top Expert 2009
Commented:
I do not want to say too much so I can only say you handled the errors but the onMetaData needs to be called, which in this case you handled errors but hence the onMetaData is not called. And some initialising is done on onMetaData, as well as starting the timer, hence when onMetaData is not called, you get your situation.

OK, now see the code snippet and replace your code, it will work fine. Since this is a direct conversion from frame code, there are some things not of best practice but I do not want to complicate stuff so I targeted your question.

Feel free to ask any more questions.

// Code taken from -
// http://www.thetechlabs.com/tutorials/audionvideo/how-to-build-a-as3-videoplayer/
 
package{
	
	import flash.display.*;
	import flash.net.*;
	import flash.media.Video;
	import flash.events.*;
 
	import flash.utils.Timer;
	import flash.geom.Rectangle;
	import flash.media.SoundTransform;
	
	
	public class PlayerScript extends Sprite {
	
 
		// ##########################
		// ################ CONSTANTS
		// ##########################
 
		// time to buffer for the video in sec.
		const BUFFER_TIME:Number				= 8;
		// start volume when initializing player
		const DEFAULT_VOLUME:Number				= 0.6;
		// update delay in milliseconds.
		const DISPLAY_TIMER_UPDATE_DELAY:int	= 10;
		// smoothing for video. may slow down old computers
		const SMOOTHING:Boolean					= true;
		
		// ##########################
		// ################ VARIABLES
		// ##########################
		
		// flag for knowing if flv has been loaded
		public var bolLoaded:Boolean					= false;
		// flag for volume scrubbing
		public var bolVolumeScrub:Boolean				= false;
		// flag for progress scrubbing
		public var bolProgressScrub:Boolean				= false;
		// holds the last used volume, but never 0
		public var intLastVolume:Number					= DEFAULT_VOLUME;
		// a net connection object for net stream and of course also a net stream object
		public var ncConnection:NetConnection;
		public var nsStream:NetStream;
		// object to store all the meta data received from the flv file
		public var objInfo:Object;
		// URLRequest to the ASP page where the strSource is defined
		// var strSource:String = root.loaderInfo.parameters.SWFFilename;
		// url to flv file
		public var strSource:String						= "hancockTrailer.flv";
		// timer for updating player (progress, volume...)
		public var tmrDisplay:Timer;
				
		// ##########################
		// ################ FUNCTIONS
		// ##########################
		
		// initialises the player on the page.
		// SOME CAPITALS USED BELOW REFERENCE THE CONSTANTS ABOVE!!! 
		public function initVideoPlayer():void {			
			// hide buttons
			mcVideoControls.btnUnmute.visible	= false;
			mcVideoControls.btnPause.visible	= false;
			
			// set the progress/preload fill width to 1
			mcVideoControls.mcProgressFill.mcFillRed.width = 1;
			mcVideoControls.mcProgressFill.mcFillGrey.width = 1;
			
			// add global event listener when mouse is released
			stage.addEventListener( MouseEvent.MOUSE_UP, mouseReleased);
			
			// add event listeners to all buttons
			mcVideoControls.btnPause.addEventListener(MouseEvent.CLICK, pauseClicked);
			mcVideoControls.btnPlay.addEventListener(MouseEvent.CLICK, playClicked);
			mcVideoControls.btnStop.addEventListener(MouseEvent.CLICK, stopClicked);
			mcVideoControls.btnMute.addEventListener(MouseEvent.CLICK, muteClicked);
			mcVideoControls.btnUnmute.addEventListener(MouseEvent.CLICK, unmuteClicked);
			mcVideoControls.mcVolumeScrubber.btnVolumeScrubber.addEventListener(MouseEvent.MOUSE_DOWN, volumeScrubberClicked);
			mcVideoControls.mcProgressScrubber.btnProgressScrubber.addEventListener(MouseEvent.MOUSE_DOWN, progressScrubberClicked);
			
			// create timer for updating all visual parts of player and add
			// event listener
			tmrDisplay = new Timer(DISPLAY_TIMER_UPDATE_DELAY);
			tmrDisplay.addEventListener(TimerEvent.TIMER, updateDisplay);
			
			// create a new net connection, add event listener and connect
			// to null because we don't have a media server
			ncConnection = new NetConnection();
			ncConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
			ncConnection.connect(null);
			
			// create a new stream with the net connection, add event
			// listener, set client to this for handling meta data and
			// set the buffer time to the value from the constant
			nsStream = new NetStream(ncConnection);
			nsStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
			
			var customClient:Object = {onMetaData:MetaDataHandler};
			
			nsStream.client = customClient;
			nsStream.bufferTime = BUFFER_TIME;
			
			// attach net stream to video object on the stage
			vidDisplay.attachNetStream(nsStream);
			// set the smoothing value from the constant
			vidDisplay.smoothing = SMOOTHING;
		
			// set default volume
			mcVideoControls.mcVolumeScrubber.x = (52 * DEFAULT_VOLUME) + 341;
			mcVideoControls.mcVolumeFill.mcFillRed.width = mcVideoControls.mcVolumeScrubber.x - 394 + 52;
			setVolume(DEFAULT_VOLUME);
		}		
		
		function playClicked(e:MouseEvent):void {
			// check's if the flv has already begun
			// to download. if so, resume playback, else
			// load the file (strSource) <-- defined above in variables
			if(!bolLoaded) {
				nsStream.play(strSource);
				bolLoaded = true;
			}
			else{
				nsStream.resume();
			}
			
			// show video display
			vidDisplay.visible					= true;
			
			// switch play/pause visibility
			mcVideoControls.btnPause.visible	= true;
			mcVideoControls.btnPlay.visible		= false;
		}
		
		function pauseClicked(e:MouseEvent):void {
			// pause video
			nsStream.pause();
			
			// switch play/pause visibility
			mcVideoControls.btnPause.visible	= false;
			mcVideoControls.btnPlay.visible		= true;
		}
		
		function stopClicked(e:MouseEvent):void {
			// calls stop function
			stopVideoPlayer();
		}
		
		function muteClicked(e:MouseEvent):void {
			// set volume to 0
			setVolume(0);
			
			// update scrubber and fill position/width
			mcVideoControls.mcVolumeScrubber.x				= 341;
			mcVideoControls.mcVolumeFill.mcFillRed.width	= 1;
		}
		
		function unmuteClicked(e:MouseEvent):void {
			// set volume to last used value
			setVolume(intLastVolume);
		
			// update scrubber and fill position/width
			mcVideoControls.mcVolumeScrubber.x = (53 * intLastVolume) + 341;
			mcVideoControls.mcVolumeFill.mcFillRed.width = mcVideoControls.mcVolumeScrubber.x - 394 + 53;
		}
		
		function volumeScrubberClicked(e:MouseEvent):void {
			// set volume scrub flag to true
			bolVolumeScrub = true;
			
			// start drag
			mcVideoControls.mcVolumeScrubber.startDrag(false, new Rectangle(341, 19, 53, 0));
		}
		
		function progressScrubberClicked(e:MouseEvent):void {
			// set progress scrub flag to true
			bolProgressScrub = true;
			
			// start drag
			mcVideoControls.mcProgressScrubber.startDrag(false, new Rectangle(0, 2, 432, 0));
		}
		
		function mouseReleased(e:MouseEvent):void {
			// set progress/volume scrub to false
			bolVolumeScrub		= false;
			bolProgressScrub	= false;
			
			// stop all dragging actions
			mcVideoControls.mcProgressScrubber.stopDrag();
			mcVideoControls.mcVolumeScrubber.stopDrag();
			
			// update progress/volume fill
			mcVideoControls.mcProgressFill.mcFillRed.width	= mcVideoControls.mcProgressScrubber.x + 5;
			mcVideoControls.mcVolumeFill.mcFillRed.width	= mcVideoControls.mcVolumeScrubber.x - 394 + 53;
			
			// save the volume if it's greater than zero
			if((mcVideoControls.mcVolumeScrubber.x - 341) / 53 > 0)
				intLastVolume = (mcVideoControls.mcVolumeScrubber.x - 341) / 53;
		}
		
		function updateDisplay(e:TimerEvent):void {
			// checks, if user is scrubbing. if so, seek in the video
			// if not, just update the position of the scrubber according
			// to the current time
			if(bolProgressScrub)
				nsStream.seek(Math.round(mcVideoControls.mcProgressScrubber.x * objInfo.duration / 432))
			else
				mcVideoControls.mcProgressScrubber.x = nsStream.time * 432 / objInfo.duration; 
			
			// set time and duration label
			mcVideoControls.lblTimeDuration.htmlText		= "<font color='#ffffff'>" + formatTime(nsStream.time) + "</font> / " + formatTime(objInfo.duration);
			
			// update the width from the progress bar. the grey one displays
			// the loading progress
			mcVideoControls.mcProgressFill.mcFillRed.width	= mcVideoControls.mcProgressScrubber.x + 5;
			mcVideoControls.mcProgressFill.mcFillGrey.width	= nsStream.bytesLoaded * 438 / nsStream.bytesTotal;
			
			// update volume and the red fill width when user is scrubbing
			if(bolVolumeScrub) {
				setVolume((mcVideoControls.mcVolumeScrubber.x - 341) / 53);
				mcVideoControls.mcVolumeFill.mcFillRed.width = mcVideoControls.mcVolumeScrubber.x - 394 + 53;
			}
		}		
 
		function MetaDataHandler(info:Object):void {
			trace("metadata");
			// stores meta data in a object
			objInfo = info;
			
			// now we can start the timer because
			// we have all the neccesary data
			tmrDisplay.start();
		}
		
		function netStatusHandler(event:NetStatusEvent):void {
			// handles net status events
			switch (event.info.code) {
				// trace a messeage when the stream is not found
				case "NetStream.Play.StreamNotFound":
					trace("Stream not found: " + strSource);
				break;
				
				// when the video reaches its end, we stop the player
				case "NetStream.Play.Stop":
					stopVideoPlayer();
				break;
			}
		}
		
		// for when the stop button is clicked
		function stopVideoPlayer():void {
			// pause netstream, set time position to zero
			nsStream.pause();
			nsStream.seek(0);
			
			// in order to clear the display, we need to
			// set the visibility to false since the clear
			// function has a bug
			vidDisplay.visible					= false;
			
			// switch play/pause button visibility
			mcVideoControls.btnPause.visible	= false;
			mcVideoControls.btnPlay.visible		= true;
		}
		
		function setVolume(intVolume:Number = 0):void {
			// create soundtransform object with the volume from
			// the parameter
			var sndTransform		= new SoundTransform(intVolume);
			// assign object to netstream sound transform object
			nsStream.soundTransform	= sndTransform;
			
			// hides/shows mute and unmute button according to the
			// volume
			if(intVolume > 0) {
				mcVideoControls.btnMute.visible		= true;
				mcVideoControls.btnUnmute.visible	= false;
			} else {
				mcVideoControls.btnMute.visible		= false;
				mcVideoControls.btnUnmute.visible	= true;
			}
		}
		
		function formatTime(t:int):String {
			// returns the minutes and seconds with leading zeros
			// for example: 70 returns 01:10
			var s:int = Math.round(t);
			var m:int = 0;
			if (s > 0) {
				while (s > 59) {
					m++;
					s -= 60;
				}
				return String((m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s);
			} else {
				return "00:00";
			}
		}
	
		public function PlayerScript(){			
			initVideoPlayer();
        }
		
	}//end Public Class PlayerScript
		
}//end Package
		
// to AUTOMATICALLY PLAY the file un comment the code below
// playClicked(null);

Open in new window

Author

Commented:
I have not abanded this topic I am very busy with differing projects going on, this is my last week with my current employer and so I am trying to tie up lose ends. Will look into this more today fingers crossed thanks for your direction!!!

Author

Commented:
Thanks very much for your help. I understand that I have bitten off 100% more than I can handle here. I was trying to cut corners to meet deadlines but its back to square one for now. Thanks very much for patience and help.
Cheers

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial