21 Replies Latest reply on Oct 22, 2007 1:50 PM by Boxing Boom

    Want a challenge? Some meaty ActionScript

    Boxing Boom Level 1
      Hi Everyone,

      Spent all day, trying to get the attached script to work, no joy and certainly, no LUCK.

      Can someone see if they can see where I am going wrong here; its a mp3 player that should use XML list and .as file, music should fade in and out etc...

      I will attach the code. GOOD LUCK! ;)

      Kind Regards,

      Boxing Boom
        • 1. Re: Want a challenge? Some meaty ActionScript
          kglad Adobe Community Professional & MVP
          what's wrong?
          • 2. Re: Want a challenge? Some meaty ActionScript
            Boxing Boom Level 1
            Hi,

            First, thank you for checking over the code, its appreciated. When the .swf is run, it returns an error, stating that lines 50 and 52, are using bolean values when there should be funtions instead; sorry but I am not a very good actionscripter, its hard for me to know exactly. Have yourself found any thing that may be causing this problem?

            Kind Regards,

            Boxing Boom
            • 3. Re: Want a challenge? Some meaty ActionScript
              clbeech Level 3
              you have 'playSong' defined as the variable AND a function name. Change one of them.
              • 4. Re: Want a challenge? Some meaty ActionScript
                Boxing Boom Level 1
                Hi,

                Thank you for your response; could you provide just a little more clarity; would your answer make it work?
                I am not a good actionscripter, I seem to find myself spending days on end, figuring out advanced scripts and piecing them together untill I get a result; I aim to get a hands on training ASAP.
                Kind Regards,

                Boxing Boom
                • 5. Re: Want a challenge? Some meaty ActionScript
                  kglad Adobe Community Professional & MVP
                  we won't know until you try it. but to be sure, that's preventing your code from working.

                  do a search for playSong() and replace each string with playSongF()
                  • 6. Re: Want a challenge? Some meaty ActionScript
                    clbeech Level 3
                    That's what I was thinking to kg, but it looks like there might be a couple of other things in there too eh? like the incrementor in the accessor, in reverse even. also the running loop to detect the change ... should work but not super I think BB.

                    Anyway, I gues I might go about it a little differently, I've made an example for you, with a fade out feature, the files here have everything you need to make it run including music (small loops) and XML, just don't take the FLA out of the folder, launch from there. Look at the restructured code on frame one (never mind the 'fake' level indicators) and maybe you can get some Ideas from that.

                    Here's the FILE FOLDER
                    • 7. Re: Want a challenge? Some meaty ActionScript
                      Boxing Boom Level 1
                      Hi Kglad & Clbeech,

                      Many many thanks to the both of you for your time and consideration; I will look at the example you've provided Clbeech, and I will try out what you've said Kglad.

                      I will post my findings, once I have worked it out, if I ever work it out.

                      Kind Regards,

                      Boxing Boom
                      • 8. Re: Want a challenge? Some meaty ActionScript
                        Boxing Boom Level 1
                        Hi,

                        After trying out what Kglad said about replacing the playSound() with playSoundF(), it plays the music. However, when I click on the button to fade it out and stop, it just restarts that track. Sods law, I guess.

                        What I ideally want is to have the fade out work, and have the sound not play until I click on the play button.

                        Nearly there, yet so far. Clbeech, your player is pretty good, but again I would want the user to press the play button to start the music.

                        I think my script has potential, if only the damn thing worked out for me.

                        Thanks for the help, I really appreciate your time spent on this.

                        Kind Regards,

                        Boxing Boom
                        • 9. Re: Want a challenge? Some meaty ActionScript
                          Boxing Boom Level 1
                          Hi,

                          I have cleaned up the code, so that it may be easier to follow; my buttons are now displaying perfectly, however no sound is playing and I do not get any error messages. I think its down to linking the buttons with the sound? ;)

                          I have attached the new code.

                          Kind Regards,

                          Boxing Boom
                          • 10. Re: Want a challenge? Some meaty ActionScript
                            lukeduke7
                            I don' t know which direction Boxing Boom will go with which code to use. For what its worth, in the original code under the Event Handler*** part, the playSong is stated with a capital "P" instead of a lowercase "p" on the else if statement.

                            Maybe this has been taken care of.
                            • 11. Re: Want a challenge? Some meaty ActionScript
                              clbeech Level 3
                              ok BB, here's the thing, the player I wrote there will toggle the music off and on, press the button again. that's what a 'toggle' switch is really, a single switch that performs two functions. Now you have music begining to play by default, whci is the way I set up my player, easily remedied if you want it to not play on open. Point is, it's more than a fair example of what you're trying to do here.

                              You'd posted, i dunno, a couple of weeks ago, with questions on this same topic. And I gave you correction to the code for the function 'playSong' and explained why what you still have there isn't working. Apparently you'd never changed it.

                              So, change the change the codes I have here below, and remove the 'toggleSound' method, you can handle this from the buttons.

                              • 12. Want a challenge? Some meaty ActionScript
                                Boxing Boom Level 1
                                Hi,

                                Nope, your code does not fix the above problems. Your code makes the buttons not invisible, and sound will not play when pressed. But BIG thanks for trying once more.

                                I'd have never guessed how hard this technique is. Unless, someone (GURU) comes along, I will have to bin it. Bit of a shame, I and members have spent a few days on it now.

                                Its for sure, down to linking the sound with the buttons when pressed.

                                Kind Regards,

                                Boxing Boom
                                • 13. Want a challenge? Some meaty ActionScript
                                  clbeech Level 3
                                  I see I have a couple of errors in the code I wrote above it should have been as below.

                                  but listen, I gave you an example that works, the restructured code in it does everything that you're asking for here, and more. It isn't 'hooked up' to the same instance that your working with, but that's up to you to apply, it's all there, and it works without error. you said it was 'pretty good' ... um excuse me but, that little app I made in 20 minutes, is what you've been strugling with for weeks. I'm just saying that you shouldn't dismiss the help you've been given. If you look at the code above, you can plainly see that I'd mis-entered a couple of simple statements that are commonly used operations, if you couldn't see how to fix them or what's wrong with them, then you really shouldn't be trying to do this sort of thing until you learn a little more.

                                  So here are the repairs ... never mind, I completely rewrote this with your variable names and instances, I KNOW this works I've tested it, replace what you have with this:
                                  • 14. Re: Want a challenge? Some meaty ActionScript
                                    Boxing Boom Level 1
                                    Hi,

                                    I've done as instructed, the file plays and when I press pause it pauses, however when I press play to play it, I get the following error:

                                    Error opening URL 'file:///C|/Users/gerry/Documents/WEBSITE%2DI%2DTUTS/xml%20player/undefined'

                                    Many thanks, you are a STAR!

                                    Kind Regards,

                                    Boxing Boom
                                    • 15. Re: Want a challenge? Some meaty ActionScript
                                      clbeech Level 3
                                      ok BB, your getting close, sorry to be so hard on you :)

                                      It looks like a path error, from the xml url address list, but that doesn't quite make sense that it would happen when pressing the 'play' button, because the only thing that button should do is bring up the volume. do you have another button in there or some other code that is attached to the button instance somewhere?

                                      also check your file paths in the xml doc to make sure they lead to the correct directory, on your system, relative to the fla file location.

                                      I'm still guessing that you have some other code on the 'play' button, check into that first.
                                      • 16. Re: Want a challenge? Some meaty ActionScript
                                        Boxing Boom Level 1
                                        Hi,

                                        Thanks, I am on it; I will check it and get back ASAP. Many many thanks. ;)

                                        Kind Regards,

                                        Boxing Boom
                                        • 17. Re: Want a challenge? Some meaty ActionScript
                                          Boxing Boom Level 1
                                          Hi,

                                          In need of this script to not play music, until user clicks the play button. Please, once this is done, we can end this topic.

                                          Kind Regards,

                                          Boxing Boom
                                          • 18. Re: Want a challenge? Some meaty ActionScript
                                            clbeech Level 3
                                            Sorry BB, I've been busy. Let me ask you, in addition to the song playing when you press the 'play', do you think the sound should actally 'stop' when you press the 'pause' button? because the way we have it working now, it plays automatically, and when paused it only turn the volume down but they continue to play without volume, then when hitting play again it bring the volume back up, and the songs continue to cycle through the list.

                                            Secondly, I'm not sure how your change to cps=-1 would have made a difference with the problem you were having where the song wouldn't play on the second press of the button, that's not how array indexs work, the only thing I can think of is that you may only have one song in the list, or somethings not right with the XML. If there was only one song, that would be it because it woudl be the only thing in the array at index 0, and I see that I should have used:

                                            if(cps < sa.length-1) {

                                            in the 'playSong' function's conditional statement, this should solve the problem, but also change the cps defaults back to zero.

                                            to stop the song from playing until pressing 'play' remove the 'playSong()' call fromt he end of the XML loading loop, then you'll need a couple of other things depending on your answer to the first questions here. because you'll need a method to start the song playing, and if we just put the playSong() call in the play button's code that would restart and advance the music each time the button is pressed, so you'll need another function to handle starting and stopping the songs.
                                            • 19. Want a challenge? Some meaty ActionScript
                                              Boxing Boom Level 1
                                              Hi,

                                              Yes, after many hours I did insert the if(cps < sa.length-1) { into the code block. Sorry, about all this, but I did want the script as follows;

                                              1. Not play until user clicks the play button.
                                              2. When the user clicks the pause button, the sound pauses, and hence when the user clicks the play button it would begin from where is was paused.

                                              To pause the sound, I have been today thinking of the following script;
                                              var pos:Number;

                                              //Pause sound
                                              function pauseSound():Void
                                              {
                                              pos=s.position;
                                              s.stop();
                                              }

                                              //Unpause sound
                                              function unPauseSound():Void
                                              {
                                              s.start(pos/1000);
                                              }

                                              But I am not very clear on how to actually use it within current script. Could this be used inline with the fade in fade out functions? Now that would be something special! When paused the sound fades WOW.

                                              I have made the change you requested cps =0;. Only one track is required to ever play, over and over, but If I can add another, whe might as well leave it that way; to play multiple sounds. But pause should be pause and no sound until user requests it, would be ideal.

                                              Once again, many many thanks.


                                              Kind Regards,

                                              Boxing Boom
                                              • 20. Re: Want a challenge? Some meaty ActionScript
                                                clbeech Level 3
                                                ok BB here you go, replace the script with this one :)
                                                • 21. Re: Want a challenge? Some meaty ActionScript
                                                  Boxing Boom Level 1
                                                  Hi clbeech,

                                                  Never have I witnessed such a person as you clbeech; you've gone the distance with this script and supported me better than any previous paid support. Your an apex example of how forums can help people; regardless of knowledge or background.

                                                  Someone from Adobe should also compliment you for the empathy that you have shown within this topic.

                                                  YOUR A STAR!

                                                  Kind Regards,

                                                  Boxing Boom