Ricky-McM
asked on
How to use document classes correctly with ActionScript 3
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
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);
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
ASKER
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.
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.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
you can alternatively call initVideoPlayer inside the constructor rather than putting all the code there.
public function PlayerScript()
{
initVideoPlayer();
}
public function PlayerScript()
{
initVideoPlayer();
}
ASKER
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)
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)
where's the function in the code at PlayerScript$iinit()
that's throwing the error?
that's throwing the error?
No error messages should appear after you handled the errors, can you please post the full source so I can test?
ASKER
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.
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);
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.
ASKER
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/
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/
i'm going to leave this in the hands of TanLiHao and stop interfering.
good luck.
good luck.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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!!!
ASKER
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
Cheers