FLASH CS4 and AS3

I constructed a slideshow in FLASH CS4. AS3 yet my tutorial in CS4 did not cover mp3 player so I used coding from a CS3 tutorial yet I found out they are incompatible. Found CS4 coding on-line for play, pause and stop buttons yet none for slider bar on volume control.
Here is code for CS3 slider -- can it be modified or replaced?
Thanks
Bette
----------Volume Slider-------------
volume_mc.slider_mc.buttonMode = true;

var drag:Boolean = false;
var rect:Rectangle = new Rectangle(0,0,87,0);

volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragThis);
volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_UP, dropThis);
stage.addEventListener(MouseEvent.MOUSE_UP, dropThis);

function dragThis(e:Event):void
{
	drag = true;
	event.target.startDrag(false,rect);
	event.target.addEventListener(MouseEvent.MOUSE_MOVE, changeVolume);
}

function changeVolume(e:Event):void
{
	var vol:Number = volume_mc.slider_mc.x * .011;
	var sndTrans:SoundTransform = new SoundTransform(vol,0);
	sndChan.soundTransform = sndTrans;
}

function dropThis(e:Event):void
{
	if(drag)
	{
		var vol:Number = volume_mc.slider_mc.x * .011;
		var sndTrans:SoundTransform = new SoundTransform(vol,0);
		sndChan.soundTransform = sndTrans;
		volume_mc.slider_mc.stopDrag();
		volume_mc.slider_mc.removeEventListener(MouseEvent.MOUSE_MOVE, changeVolume);
		drag = false;
	}
}

Open in new window

Bette LamoreWeb Designer/Developer/GIS ProfessionalAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

IqAndreasCommented:
That CS3 slider should work just fine for CS4 as well. There is really not much difference at all between the two versions.

Have you tried the code you supplied already? What exactly was wrong with it?

Are you having a problem with the actual slider, or are you having a problem controlling the volume?

Here is a nice slider tutorial:
http://www.gotoandlearn.com/play?id=81

And there are LOTS of volume tutorials on google:
http://www.google.com/search?q=as3+change+volume+sound
Bette LamoreWeb Designer/Developer/GIS ProfessionalAuthor Commented:
I have tried the code yet it breaks my whole slideshow. I have AS3 for all the rest of the code. I had the stop and play buttons coded with CS3 code and it broke the program until I substituted CS4 code and then it worked. In fact, I couldn't find a separate CS4 code for the pause button so I combined it with the play button and it worked so there is a conflict between the AS2 coding and AS3 coding.
I'll go to the tutorial at gotoandloearn and come back.
I have exhausted Google yet I was searching for FLASH CS4 slider bar so I'll try your suggestion. I'm in the country thought so by the time I dowload the video file (takes forever) only to find they were talking about CS3, it is very frustrating.
 If I find something from your first link, though -- you get the points!! Thanks
I'm hoping someone actually comes up with the code, though so I don't have to spend another 4 hours looking.
blue-genieCommented:
um you're confused between CS and AS. CS in the IDE i.e the version of flash and AS is Actionscript, the language you use to write code in.
both version CS3 and CS4 can handle AS2 and AS3, it is possible to bridge (i.e use both together) to a degree, but it's not advisable.
if you follow IqAndreas comments and clear up what you're using and what you're doing I'm sure he can help you out.

good luck.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Bette LamoreWeb Designer/Developer/GIS ProfessionalAuthor Commented:
I'm sorry -- in a hurry with my reply to IqAndreas. I used FLASH CS4 to create my sludeshow and that version of FLASH uses AS3. I not only have an internal AS file in my fla project, but I also have an external AS3 file for the picture class to upload my pics used in the slideshow.
Because I did not have a tutorial for building an mp3 player to regulate the soundtrack for CS 4, I used a tutorial for FLASH CS 3 -- which broke my slideshow. They are NOT always compatitble.
I located a FLASH CS 4 tutorial for the stop, pause and play buttons and now those buttons work GREAT!! My problem is that I have not yet been able to locate a tutorial for the volume slider (see FLASH CS3 -- AS 2 code above. All I am asking for is that short code in AS 3. I'm not confused -- just frustrated!
I spent an hour (live in the country) downloading the video in the first link which IqAndreas suggested only to learn that is was only geared for FLASH 8 and was written in AS2.
This is frustrating -- hasn't anyone here ever used controls for a soundtrack on their FLASH web site with a volume slider bar?? I'm beginning to believe I am a pioneer.
IqAndreasCommented:
Okay. I'll try clearing some things up for you if it helps.

Flash 8 was software owned by Macromedia. It could only run Action Script 2 (abbreviated AS2).

Then, Adobe bought the rights to create Flash from Macromedia, and renamed the NEW program Flash Processional CS3. Flash CS3 had several new features, but the main feature was Action Script 3.0 (abbreviated AS3). ActionScript 3 was quite different from AS2. It had a little different structure, and added a lot of new features not previously available to AS2 developers. Still, both are a bit similar to eachother, so most code can be easily converted from one to the other by changing things in the code here and there.

However, Flash developers didn't want to learn an entirely new library of code just in order to keep making Flash stuff. So, what Adobe did was keep AS2 and AS3 support in Flash CS3. This means that both AS2 and AS3 developers can use the same program and don't need to buy separate software for the two languages. This made it a lot easier for many developers.

A few years later, Adobe released Flash Professional CS4, which is almost exactly like Flash CS3. Flash CS4 also allowed both AS2 and AS3 to make it easier for developers who were used to the old language. In a few months, Adobe is completely releasing Flash CS5, which again is exactly the same thing, with a few more features.

However, the programming languages AS2 and AS3 remain unchanged in the way they work.


Is there anything you would like me to clarify further? I have made a few more clarifications like this in the past on my blog (I might even copy the list above and paste it in to a new post if it is clear enough)
http://iqandreas.blogspot.com/


So, with that clarified, are you looking for a slider class written in ActionScript 2 or 3? Or are you looking for volume control for AS2 or AS3?

Andreas
Bette LamoreWeb Designer/Developer/GIS ProfessionalAuthor Commented:
If you just read my original post above you will see that I want to code fixed so it will work. My instructor in FLASH said that CS3 uses AS 2. I created my site in CS4. I found code from a CS3 tutorial and it didn't work in my CS4 constructed site so I assume the tutorial was created using AS2. I have no way of checking that since the instructor did not say nor show which version of AS the tutorial used. All I know is that the code did not work.
I found AS 3 code for 3 buttons (see above) and it works.
My original question was that I needed AS 3 code.
Obviously I did not spell everything out as I assumed you would know that CS3 and CS4 referred to which version of FLASH I was using -- obviously I confused you and for that I am sorry.
AS3 is available in CS4 and was used in the tutorial. Since the Tutorial fo FLASH CS3 is NOT working, yet it worked for the instructor in the tutorial, I assumed she used AS2 and it is not compatible with my AS4 code.
Am I clear now??
All I want is the code for a volume control slider. I guess that is beyond everyone here -- all I am getting is a lesson on semantics.
I'll go elsewhere rather than remain to be talked down to and register my complaint next time I'm in Arroyo Grande -- really -- trying to make me sound stupid was totally unnecessary on your part.
I have had good results with EE in the past -- not sure I want to continue with my membership now.
Bette LamoreWeb Designer/Developer/GIS ProfessionalAuthor Commented:
oops typo -- fingers too fast for brain -- "I assumed she used AS2 and it is not compatible with my AS3 code."
blue-genieCommented:
i am very confused so not to make matters work i'll leave you in the hands of Iq..

just 2 quick things,"see FLASH CS3 -- AS 2 code above." SoundTransform in AS3 so that snippet is not AS2 so not sure why you're asking for it to be changed.  I think you'll be better off uploading the file you have.

@Iq "However, the programming languages AS2 and AS3 remain unchanged in the way they work." I believe too many people are trying to build things the way they used to in AS2 and running into errors and then berating Flash, however AS3, if used correctly should be used in the intended Document Class structure, but that's another issue entirely.

IqAndreasCommented:
Hm... Why does everyone keep saying, "I'll leave you in the hands of IqAndreas now"? I thought this was more like a "group help" sortof thing... ;)


You REALLY need to get this clear. Sorry for being so harsh, but read through this until you understand it, and ask if you want me to elaborate.

ActionScript 2 (AS2) and ActionScript 3 (AS3) are two VERY different languages. It is NOT possible to mix AS2 and AS3 into one FLA (Flash File). There is no such thing as AS4 yet.

Flash CS3 and Flash CS4 are the exact same thing. Both are made for AS3, however, it is possible to do AS2 inside of them.

Any tutorials written for CS3 will work in CS4.
Any tutorials written for AS2 will NOT work in AS3.


Do you understand the difference?
Bette LamoreWeb Designer/Developer/GIS ProfessionalAuthor Commented:
IqAndreas:
Yes, I understand everything you just wrote -- I don't know how to make you understand that I understand that fully.In my opening question I said I tried to use the tutorial geared for FLASH CS 3 for a fla file I created in FLASH CS4. Will you PLEASE re-read my first post and you will see that I said EXACTLY what you just wrote -- that a project created in CS4 will not allow code geared for CS3.

Now, that being said  I still need code for the volume slider bar that will work in a CS4 fla. I assumed that the AS version in the CS3 tutorial was AS2 (I have no way of knowing that except for the fact that the code does not work in my CS 4 fla). It is a little insulting to suggest to me that I try the code-- it should work. I wouldn't be here asking for code if it worked. The whole mp3 player that I created following the CS 3 tutorial did NOT work so I went on-line and found a tutorial for CS4 stop/play/pause buttons and they now work. I cannot find a tutorial for CS4 on how to make the slider bar work

Now, does that make sense to you?? I cannot ask the question any more clearly than I have already. Since Genius has determined that my code written above is AS3, then that is not the problem, apparently and we are back to my original question that a project completed in CS 4 is incompatible with code written for CS3.

Sooo can anyone help here, now that we have the semantics HOPEFULLY out of the way?
blue-genieCommented:
haha IqAndreas: - I speak for myself here, but I know some of the "older" furniture around here feel the same.
We try to respect other volunteers efforts and not interfere if someone is trying to resolve the problem
otherwise it becomes a case of too many cooks.

i will add my 2cs if I don't agree with something or if it seems that they're going around  in circles but otherwise I rather back off.
blue-genieCommented:
@woolamore

"I guess that is beyond everyone here -- all I am getting is a lesson on semantics.
I'll go elsewhere rather than remain to be talked down to and register my complaint next time I'm in Arroyo Grande -- really -- trying to make me sound stupid was totally unnecessary on your part.
I have had good results with EE in the past -- not sure I want to continue with my membership now."

Semantics is actually important in this case when we're trying to determine which language we are using. It makes a big difference. No one is trying to make you sound stupid, just trying to make sure you understand so that you can explain to us so we can try and help you. Please bear in mind that we are all volunteers, we spend our time trying to help in the interest of knowledge sharing, we get nothing else from it.

i'm going to step in here  now .. sorry Iq.

Ok, first of all please go back to your Flash teacher and correct him/her about CS3 only allowing AS2.
Then, there's no reason why the CS3 file won't work in CS4, as I can see you're not using any components (i could be wrong)
What error messages are you getting? Check your output window and compiler errors.

Ok, so let's first fix some syntax issues.

// ------------

function dragThis(e:Event):void
{
      drag = true;
      event.target.startDrag(false,rect);
      event.target.addEventListener(MouseEvent.MOUSE_MOVE, changeVolume);
}
//----------------

 you have the argument (e:Event) - yet in the function body you're referring to event, so that should give you a reason why it doesn't work

so either change the argument to (event:Event);
or change the references of event to e in the function body

//shout if you need further explanation on that

then i do a quick setup of a slider and paste your code in there, and it works just fine.

make sure you have all the required imports and that you've declared everything properly. I'm assuming there is other stuff that needs to be in place included in that tutorial that you've just not included in your snippet.


hmmm having problems including file and snippet.
blue-genieCommented:
here u go. should give you an idea.
import flash.events.MouseEvent;
import flash.net.URLRequest;

import flash.media.Sound;
var sndChan:SoundChannel;
var soundFactory:Sound;

var url:String="abc.mp3";
var request:URLRequest = new URLRequest(url);

soundFactory = new Sound();

soundFactory.load(request);
sndChan=soundFactory.play();
//----------Volume Slider-------------
volume_mc.slider_mc.buttonMode=true;

var drag:Boolean=false;
var rect:Rectangle=new Rectangle(0,0,87,0);

volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragThis);
volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_UP, dropThis);
stage.addEventListener(MouseEvent.MOUSE_UP, dropThis);

function dragThis(e:Event):void {
	drag=true;
	e.target.startDrag(false,rect);
	e.target.addEventListener(MouseEvent.MOUSE_MOVE, changeVolume);
}

function changeVolume(e:Event):void {
	var vol:Number=volume_mc.slider_mc.x*.011;
	var sndTrans:SoundTransform=new SoundTransform(vol,0);
	sndChan.soundTransform=sndTrans;
}

function dropThis(e:Event):void {
	if (drag) {
		var vol:Number=volume_mc.slider_mc.x*.011;
		var sndTrans:SoundTransform=new SoundTransform(vol,0);
		sndChan.soundTransform=sndTrans;
		volume_mc.slider_mc.stopDrag();
		volume_mc.slider_mc.removeEventListener(MouseEvent.MOUSE_MOVE, changeVolume);
		drag=false;
	}
}

Open in new window

blue-genieCommented:
and the file.
Untitled-1.fla.txt

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
IqAndreasCommented:
I am VERY sorry.

I did not mean in any way to imply that you are stupid, and I sincerely apologize for giving off any such impression.

I just know that keeping track of all the different AS2, CS4, FB3, AS3, Flash, Flex, and AIR, can be VERY confusing for both beginner and experts alike. I had a VERY difficult time keeping track of the differences when I started out programming, and I still do. (Cursed Adobe and their darned abbreviations!) I just wanted to make sure you completely understood the differences.


Thank you blue-genie for stepping in. :)

If you are still having slight issues when dragging the slider, try changing the "e.target" lines to "e.currentTarget", but it all depends on how the graphics for your slider are set up.


Again, I really apologize for giving off any negative impressions. I really do want to help to the best of my ability, but sometimes I get carried away.

Sincerely,
Andreas Renberg
Bette LamoreWeb Designer/Developer/GIS ProfessionalAuthor Commented:
WOW!!! Thank you soooo much, Blue_Genie!! The only problem was my e:Event vs event:Event -- that will prevent MUCHO MUCHO headaches in the future to be aware of that!! One little change and all is well!!!
Thank you too, Andreas (Don't have the spelling in front of me. I realize now you were only trying to be helpful.
Have GREAT Days, both of you!!
Bette LamoreWeb Designer/Developer/GIS ProfessionalAuthor Commented:
Thank you for your efforts,IqAndreas. I realize now you were only trying to be helpful.
Have a GREAT Day!
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
Multimedia Programming

From novice to tech pro — start learning today.