20 Replies Latest reply on Mar 5, 2007 3:53 PM by kglad

    parts of an audio player

    kesed_millay
      I'm not very skilled with actionscript yet, so bare with me. And I'm going to apologize ahead of time for stupid mistakes that I'm bound to make. As the title suggests I'm working on making an audio player for an all flash site. I think I have most of the script down for the basic functions of the player. The player I'm making will dynamically load mp3s and their "info" through an xml file. At this stage of devolopement I'm trying to figure out how to make a basic volume slider that I can put in with the player. I probably have the hard stuff down and am stuck on the easy stuff. Go figure. Would anyone be so kind as to stoop down to my level and give me some starters on how to get this slider down? Or if anyone has a tutorial that they could point me towards that would be great too! Thanks.
        • 1. Re: parts of an audio player
          kglad Adobe Community Professional & MVP
          1. create your slider/track in the authoring environment.
          2. determine to extremes of the slider's position (_x or _y property, if horizontal or vertical, resp.);
          3. set up a linear equation the returns the volume given the slider's position. ie, when the slider is at its minimum, the volume is 0 and when the slider is at its max, the volume is 100.
          4. initiate a startDrag() when the slider is pressed and initiate a loop that returns the sound's volume given the slider's position.
          • 2. Re: parts of an audio player
            kesed_millay Level 1
            thank you kglad for your advice! i'm sure that anyone with a little more actionscript knowledge would be able to make this mp3 player work, but i'm just getting stuck. i've written out most of the code for it, and it doesn't work. the mp3's don't play. maybe you could help me out with this bigger problem? i think that the volume slider is correct, but i won't know until i can get the mp3's to play. i will include my script for the whole project, and also the syntax errors that it gives me.

            here are the errors:

            **Error** Scene=Scene 1, layer=actions other, frame=1:Line 1: Clip events are permitted only for movie clip instances
            onClipEvent (load) {

            **Error** Scene=Scene 1, layer=actions other, frame=1:Line 5: Clip events are permitted only for movie clip instances
            onClipEvent (enterFrame) {

            **Error** Scene=Scene 1, layer=actions, frame=1:Line 21: Function name expected
            {

            **Error** Scene=Scene 1, layer=actions, frame=1:Line 25: ')' or ',' expected
            sa.push(newSong (nodes .attributes.url, nodes.attributes.artist, nodes .attributes.track);

            **Error** Scene=Scene 1, layer=actions, frame=1:Line 33: '{' expected
            function playSong():Void

            **Error** Scene=Scene 1, layer=actions, frame=1:Line 51: Syntax error.
            fuction pauseIt():Void

            **Error** Scene=Scene 1, layer=song class, frame=1:Line 1: Syntax error.
            class Song

            **Error** Scene=Scene 1, layer=song class, frame=1:Line 3: Syntax error.
            public var earl:String;

            **Error** Scene=Scene 1, layer=song class, frame=1:Line 4: Syntax error.
            public var artist:String;

            **Error** Scene=Scene 1, layer=song class, frame=1:Line 5: Syntax error.
            public var track:String;

            **Error** Scene=Scene 1, layer=song class, frame=1:Line 7: Syntax error.
            public function Song(e:String, a:String, t:String)

            Total ActionScript Errors: 11 Reported Errors: 11

            Error opening URL "file:///G|/mp3%20player/sound2.mp3"




            and here is the main bunch of script.
            • 3. Re: parts of an audio player
              kesed_millay Level 1
              and the sound class script

              • 4. Re: parts of an audio player
                kesed_millay Level 1
                and the script for the volume slider

                • 5. Re: parts of an audio player
                  kglad Adobe Community Professional & MVP
                  flash isn't even trying to execute your code because you are generating fatal compiler errors. you must fix the obvious errors before you can really get started.

                  first, you have an
                  onClipEvent (load) { ..

                  and

                  onClipEvent (enterFrame) {..

                  attached to your first frame and they need to be removed. next you have a missing paranthesis in your push method. next you have function misspelled (twice). i don't see newSong() defined anywhere.

                  the code below is free of compiler errors but you have more code on your timeline and you need more code.



                  • 6. Re: parts of an audio player
                    kesed_millay Level 1
                    that had to be annoying to look at. i'm sorry. i'm going to take some time to try to sort things out. i'll let you know once i get stuck again. thank you!
                    • 7. Re: parts of an audio player
                      kglad Adobe Community Professional & MVP
                      you're welcome.
                      • 8. parts of an audio player
                        kesed_millay Level 1
                        i have the mp3 player part working now. it has a basic play/pause, and a next button. but the volume slider doesn't work. the volume slider actionscript is still the same as above.
                        • 10. Re: parts of an audio player
                          kesed_millay Level 1
                          i inserted that script, but for some reason everytime i click on the slider it disappears and takes the volume to 0. sorry that i'm not getting this.
                          • 11. Re: parts of an audio player
                            kglad Adobe Community Professional & MVP
                            then, at least, some of the parameters in your startDrag() method are incorrect. use a trace(this._x+" "+this._y) in your dragger.onPress method to see what _x and _y properties your dragger has before it's dragged.

                            that _x value should be between your left and right parameters or your dragger will jump (left or right) when pressed. and your dragger's initial _y should be between your top and bottom parameters or your dragger will jump (up or down).
                            • 12. Re: parts of an audio player
                              kesed_millay Level 1
                              i think i need to explain that i'm using a vertical slider. i want to be able to place it anywhere on the stage. with the current script that i have, it takes the volume to zero but doesn't let you drag the slideBar but, it doesn't disappear anymore. i think i understand you to be saying that the slideBar.startDrag(true, 0, slider._y, 0, 0); line of code needs to be edited. but i'm not sure what to edit it to. i've messed around a bit with it, but i can't find the answer.
                              • 13. parts of an audio player
                                kesed_millay Level 1
                                can anyone help me out with this script. i'm basically back to the volume slider. i don't know how to make the slider drag.
                                • 14. Re: parts of an audio player
                                  kglad Adobe Community Professional & MVP
                                  the code you originally posted was not for a vertical slider. the latest code you posted would be for a vertical slider.

                                  you need to know a few things to make your slider work. first, you need to know the instance name of the movieclip that you want to be able to drag. i'm not sure you have that correct with your latest code.

                                  second, you need to know the extremes of your draggable movieclip's _y property when it's dragged.

                                  third, you need to use those movement limits in the startDrag() parameters to restrict your draggable movieclip to the limits you want.

                                  and fourth, you need to set the volume of your sound according to the position of the draggable movieclip.
                                  • 15. Re: parts of an audio player
                                    kesed_millay Level 1
                                    thank you...i'll work on that.
                                    • 16. Re: parts of an audio player
                                      kglad Adobe Community Professional & MVP
                                      you're welcome. make use of the trace() function. it's very rare that a problem can't be pinpointed using it.

                                      one helpful thing to know when trying to target movieclips is that you can always put trace(this) on the timeline of any movieclip that you might be targeting incorrectly. the output panel will reveal the absolute path to the movieclip.
                                      • 17. Re: parts of an audio player
                                        kesed_millay Level 1
                                        thanks i'll make use of that. i'll probably have more problems with this mp3 player, if i do i'll definitely post them on this forum.
                                        • 18. Re: parts of an audio player
                                          kglad Adobe Community Professional & MVP
                                          good luck!
                                          • 19. Re: parts of an audio player
                                            kesed_millay Level 1
                                            as was predictable i have more actionscript questions. i posted my next one as a new topic. thank you for all the help that you've given me.
                                            • 20. Re: parts of an audio player
                                              kglad Adobe Community Professional & MVP
                                              you're welcome. i responded to your other thread.