Hi All,
i’m trying to set up my video player with as3.
Now i’d like to use a volume control bar, but i got this strange error for me(not really familiar with as3):
TypeError: Error #1009: Cannot access a property or method of a null object reference.
I was looking on other topic here, but i couldn’t understand anything.
Could someone help me, please?
here my code (is not a document class. is inside my .fla)
import fl.controls.*;
import fl.events.SliderEvent;
import flash.media.SoundTransform;
var videoConnection:NetConnection = new NetConnection();
videoConnection.connect(null);
var videoStream:NetStream = new NetStream(videoConnection);
videoStream.play("shortmovie.flv");
var metaListener: Object = new Object();
metaListener.onMetaData = onMetaData;
videoStream.client = metaListener;
var video:Video = new Video();
//SET UP WIDTH AND HEIGH//
video.width = 700;
video.height = 455;
// VIDEO POSITION//
video.x = 49;
video.y = 45;
//Video Volume
var volumeTransform:SoundTransform;
volumeSlider.value = volumeTransform.volume;
volumeTransform = new SoundTransform();
volumeSlider.minimum = 0;
volumeSlider.maximum = 1;
volumeSlider.snapInterval = 0.1;
volumeSlider.tickInterval = volumeSlider.snapInterval;
volumeSlider.liveDragging = true;
volumeSlider.addEventListener(SliderEvent.CHANGE, volumeChangeHandler);
// ATTACH VIDEO ON THE STAGE
video.attachNetStream(videoStream);
addChild(video);
// FUnction play and stop movie//
function onMetaData(data:Object):void {
play_btn.addEventListener(MouseEvent.CLICK, playMovie);
stop_btn.addEventListener(MouseEvent.CLICK, stopMovie);
back_btn.addEventListener(MouseEvent.CLICK, backMovie);
}
function playMovie(event:MouseEvent):void {
videoStream.play("shortmovie.flv");
}
function stopMovie(event:MouseEvent):void {
videoStream.pause();
}
function backMovie(event:MouseEvent):void {
videoStream.seek(0);
}
function volumeChangeHandler(event:SliderEvent):void {
volumeTransform.volume = event.value;
videoStream.soundTransform = volumeTransform;
}
Thanks in advance