ActionScript 3. Error 1046: SliderEvent

I've a code for SliderEvent, when you slide the volume_mc (black vertical bar) for volume to go up or down, you'll see a number as text from 0 to 100 when you adjust the volume. As attached image of SliderEvent as below.

I've included a full code Snippet ID=8241735 with all of the buttons functions etc and the full image 'Audio work without SliderEvent'.

The error 1046 on Line 117: Type was not found or was not a compile-time constant: SliderEvent.

I would appreciate a suggested solution, please.

////////////////////////////
//attatch/import the music file.  
var musicPiece:Sound = new Sound(new URLRequest("audio/Music2.mp3"));  
  
// Make a sound channel to change sound configurations.  
var mySoundChannel:SoundChannel;  
  
// This variable is checking if the music is playing  
var isPlaying:Boolean = false;  
  
// to remember the position of the music playing when we pause, _   
to start at the same place  
  
  
var pos:Number = 0;  
  
// First button we will make is a play button, add an eventlistener.  
play_btn.addEventListener(MouseEvent.CLICK, play_);  
  
function play_(event:Event):void {  
//Check if the music is NOT playing, then make it start.  
if (!isPlaying) {  
mySoundChannel = musicPiece.play(pos);  
isPlaying = true;  
}  
}  
  
// The pause button, here we will use the pos variable we made earlier.  
pause_btn.addEventListener(MouseEvent.CLICK, pause_);  
  
function pause_(event:Event):void {  
// if the music is player, save the current time and stop the playing.  
if (isPlaying) {  
pos = mySoundChannel.position;  
mySoundChannel.stop();  
isPlaying = false;  
}  
}  
  
// Now the final button is the stop button, allmost thet same as pause  
stop_btn.addEventListener(MouseEvent.CLICK, stop_);  
  
function stop_(event:Event):void {  
// First we check if there is anything to stop then make it stop, and reset the pos variable to 0 (start time)  
if (mySoundChannel != null) {  
mySoundChannel.stop();  
pos = 0;  
isPlaying = false;  
}  
}  
  
// this is a bit complicated, but I will try to explain anyway.  
// first we make a rectangle and set its width to 100.  
var rectangle:Rectangle = new Rectangle(0,0,100,0);  
  
// then we need a varible to check if the handle is being dragged.  
var dragging:Boolean = false;  
  
// the eventlistener for startdragging  
volume_mc.mySlider_mc.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);  
function startDragging(event:Event):void {  
  
// here we tell flash the margin on where it should be able to drag, (remember 100 pixels back and forth)  
volume_mc.mySlider_mc.startDrag(false,rectangle);  
dragging = true;  
  
// This is very important, an eventlistener so we can change the volume, not only make it look good.  
volume_mc.mySlider_mc.addEventListener(Event.ENTER_FRAME, adjustVolume);  
}  
  
// well here is the adjust volume function, its not that complicated  
function adjustVolume(event:Event):void {  
  
// we make a variable to calculate the volume from the slider handle position and divide it by 100  
var myVol:Number = volume_mc.mySlider_mc.x / 100;  
// then we set it with the mySoundTransform  
var mySoundTransform:SoundTransform = new SoundTransform(myVol);  
if (mySoundChannel != null) {  
mySoundChannel.soundTransform = mySoundTransform;  
}  
}  
  
// and of cause the stop draggin function, I dont feel the need to explain it.  
stage.addEventListener(MouseEvent.MOUSE_UP, stopDragging);  
function stopDragging(event:Event):void {  
if (dragging) {  
dragging = false;  
volume_mc.mySlider_mc.stopDrag();  
}  
} 


var format:TextFormat = new TextFormat();
format.font = "Arial Black";
format.color = 0xFFFF00;
format.size = 14;
	
//info.defaultTextFormat = format;


/*this.onEnterFrame=function(){
	ratio.text=volume_mc.mySlider_mc.ratio;
	if (Key.isDown(Key.ENTER)) volume_mc.mySlider_mc.line._xscale=lineLength.text;
}*/

import fl.events.SliderEvent;
//var snd:Sound;
//var channel:SoundChannel;
//var trans:SoundTransform;
//
////create variables to store values for the current song and it's volume and pan settings.
//var currVol:Number = .5;

volume_mc.mySlider_mc.addEventListener(SliderEvent.CHANGE, volumeChange);

// uses volume slider value to control volume
function volumeChange(e:SliderEvent):void {
	currVol = e.target.value;
	ratio.text = "Current Volume: " + int(currVol*100);
	trans.volume = currVol;
	channel.soundTransform = trans;
}

Open in new window

Screen-shot-2011-12-22-at-15.25..png
Screen-shot-2011-12-22-at-15.27..png
RedscrapbookAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

conagramanCommented:
make sure you add  all of your imports
0
conagramanCommented:
you might be missing

import fl.controls.Slider;
0
RedscrapbookAuthor Commented:
I've added

import fl.controls.Slider;

no luck and tried

import fl.controls.SliderEvent;

Is it var missing, please advise?
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

conagramanCommented:
ok

add these imports as well

import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.geom.Rectangle;
import fl.events.SliderEvent;
import flash.text.TextField;


and uncomment your vars  - remove the // from these

var snd:Sound;
var channel:SoundChannel;
var trans:SoundTransform;
0
conagramanCommented:
and uncomment
remove the //
//var currVol:Number = .5;
0
RedscrapbookAuthor Commented:
No Luck, I'm sorry.

I've included a screen grand of the image of how it look now after adding the impor flash.XXXt and some variables. The more you add  impor flash.XXXt and some variables and music doesn't play at all. It did work not now.

I've enclosed all the current code including import flash.XXXt and some variables additions as below:

//attatch/import the music file.  
var musicPiece:Sound = new Sound(new URLRequest("audio/Music2.mp3"));  
  
// Make a sound channel to change sound configurations.  
var mySoundChannel:SoundChannel;  
  
// This variable is checking if the music is playing  
var isPlaying:Boolean = false;  
  
// to remember the position of the music playing when we pause, to start at the same place  
  
var pos:Number = 0; 
  
// First button we will make is a play button, add an eventlistener.  
play_btn.addEventListener(MouseEvent.CLICK, play_);  
  
function play_(event:Event):void {  
//Check if the music is NOT playing, then make it start.  
if (!isPlaying) {  
mySoundChannel = musicPiece.play(pos);  
isPlaying = true;  
}  
}  
  
// The pause button, here we will use the pos variable we made earlier.  
pause_btn.addEventListener(MouseEvent.CLICK, pause_);  
  
function pause_(event:Event):void {  
// if the music is player, save the current time and stop the playing.  
if (isPlaying) {  
pos = mySoundChannel.position;  
mySoundChannel.stop();  
isPlaying = false;  
}  
}  
  
// Now the final button is the stop button, allmost thet same as pause  
stop_btn.addEventListener(MouseEvent.CLICK, stop_);  
  
function stop_(event:Event):void {  
// First we check if there is anything to stop then make it stop, and reset the pos variable to 0 (start time)  
if (mySoundChannel != null) {  
mySoundChannel.stop();  
pos = 0;  
isPlaying = false;  
}  
}  
  
// this is a bit complicated, but I will try to explain anyway.  
// first we make a rectangle and set its width to 100.  
var rectangle:Rectangle = new Rectangle(0,0,100,0);  
  
// then we need a varible to check if the handle is being dragged.  
var dragging:Boolean = false;  
  
// the eventlistener for startdragging  
volume_mc.mySlider_mc.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);  
function startDragging(event:Event):void {  
  
// here we tell flash the margin on where it should be able to drag, (remember 100 pixels back and forth)  
volume_mc.mySlider_mc.startDrag(false,rectangle);  
dragging = true;  
  
// This is very important, an eventlistener so we can change the volume, not only make it look good.  
volume_mc.mySlider_mc.addEventListener(Event.ENTER_FRAME, adjustVolume);  
}  
  
// well here is the adjust volume function, its not that complicated  
function adjustVolume(event:Event):void {  
  
// we make a variable to calculate the volume from the slider handle position and divide it by 100  
var myVol:Number = volume_mc.mySlider_mc.x / 100;  
// then we set it with the mySoundTransform  
var mySoundTransform:SoundTransform = new SoundTransform(myVol);  
if (mySoundChannel != null) {  
mySoundChannel.soundTransform = mySoundTransform;  
}  
}  
  
// and of cause the stop draggin function, I dont feel the need to explain it.  
stage.addEventListener(MouseEvent.MOUSE_UP, stopDragging);  
function stopDragging(event:Event):void {  
if (dragging) {  
dragging = false;  
volume_mc.mySlider_mc.stopDrag();  
}  
} 


/////////////////////////////////////////

var format:TextFormat = new TextFormat();
format.color = 0xFFFF00;
format.size = 14;

//info.defaultTextFormat = format;

import fl.events.Slider;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.geom.Rectangle;
import fl.events.SliderEvent;
import flash.text.TextField;

var snd:Sound;
var channel:SoundChannel;
var trans:SoundTransform;

////create variables to store values for the current song and it's volume and pan settings.
var currVol:Number = .5;

import fl.controls.SliderEvent;
volume_mc.mySlider_mc.addEventListener(SliderEvent.CHANGE, volumeChange);

// uses volume slider value to control volume
function volumeChange(e:SliderEvent):void {
	currVol = e.target.value;
	ratio.text = "Current Volume: " + int(currVol*100);
	trans.volume = currVol;
	channel.soundTransform = trans;
}

Open in new window

Screen-shot-2011-12-22-at-18.39..png
0
conagramanCommented:
can you upload the fla - i will take a look at it

0
RedscrapbookAuthor Commented:
I've tried to upload audio.fla file or audio.zip I keep getting The extension of one or more files in the archive is not in the list of allowed extensions: bin/SymDepend.cache
0
RedscrapbookAuthor Commented:
I've attached fla (CS5) on a zip file as problem.zip and it can be downloaded:
www.kerrydeaf.com/problem.zip
0
conagramanCommented:
redscrapbook

there is a lot wrong with this. i'm sorry but i really dont have time to write this for you.
you can do this.  take all the code out and start from scratch. learn about the mouse events.

perhaps another expert will write this for you otherwise you should contact the author of the script  you are using

http://blog.0tutor.com/post.aspx?id=202
0
RedscrapbookAuthor Commented:
Ok, thank you and I appreciated it. I'll have to use a different approach then.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RedscrapbookAuthor Commented:
Dropped it altogether and use a different approach.
0
blue-genieCommented:
just for FYI - you don't have an instance of the slider component in your library. If you drag on onto the stage and then delete it you'll find that error will no longer persist.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.