12 Replies Latest reply on Aug 6, 2007 11:19 AM by _name

    Multi event button

    mattypee

      Newbie......

      I have a button that I would like to use as a hyperlink to the home page of our site. With this link I would like it to play a sound and then execute the "link to the home page. Currently, I have the hyperlink working, it forwards to the home page and it play the sound, but it does not the play the sounds in full. The sounds only play until the hyperlink does it its job of linking me the homepage.
      Is there a way in the actionscript of the button that I could play the sound bit in full, and then execute the getUrl function.

      Thanks for any help in advance

        • 1. Re: Multi event button
          kglad Adobe Community Professional & MVP
          use the sound class to start your sound. you can then use its onSoundComplete method to execute your getURL() function
          • 2. Re: Multi event button
            mattypee Level 1
            Forgive me for being so new at this, but can you provide some sample code. I am using Flash 8

            Thanks,
            Mattypee
            • 3. Multi event button
              _name Level 1
              make sure that the sound you are using as "yourSound" has been imported to your library (file > import > import to library) and is not on your time line. open your library (f11), right-click on your imported sound and select linkage; next, check export for actionscript and make sure export in first frame is checked; lastly, in the identifier text field, enter the text "yourSound."
              • 4. Re: Multi event button
                mattypee Level 1
                I've applied the code and changed the attributes as giving above and I am getting a "Statement must appear within on handler" in four different places...

                Any ideas?
                • 5. Re: Multi event button
                  mattypee Level 1
                  I have tried this code and it works, but the problem is i have to click on the button twice in order for it work. The first click is nothing...

                  on(release){
                  yourSound = new Sound ();
                  yourSound.attachSound("yourSound");
                  yourSound.setVolume(100);


                  enterSite.onRelease = function () {
                  yourSound.start(0,0);
                  yourSound.onSoundComplete = function () {
                  getURL(" http://www.cnn.com/");
                  }
                  }
                  }
                  • 6. Multi event button
                    _name Level 1
                    flash is most likely responding with "statement must appear within on handler" either because you have the code i sent you on the same layer and frame as your button or directly on the button object itself.
                    delete your existing button code. make a new layer, place it atop all others, and label it "actions." copy and paste the script i sent you above in the actions layer on the same frame as your button and it will work.
                    • 7. Re: Multi event button
                      mattypee Level 1
                      I got it to work with this code:

                      on (rollOver){
                      yourSound = new Sound ();
                      yourSound.attachSound("yourSound");
                      yourSound.setVolume(100);


                      enterSite.onRelease = function () {
                      yourSound.start(0,0);
                      yourSound.onSoundComplete = function () {
                      getURL(" http://www.cnn.com/");
                      }
                      }
                      }

                      On my machine if I publish it and run it work fine (Play the sound in full, and then links to cnn.com) after I tell give it the right flash player permission to communicate with the interent. But if someone else runs the same files (html, and the SWF) all that happens the sound play but no hyperlink to cnn.com.

                      Is this something to do with publish settings or the flash player settings.

                      How am able to get people able to use the internet with my page, so they can get forwarded off to cnn.com or example?
                      • 8. Re: Multi event button
                        _name Level 1
                        take that code off of your button and put the code i sent you on the main timeline in a layer labeled "actions." make sure the actions layer is at the top of your layer heap and also make sure the code i sent you exists within the "actions" layer on the same frame as your button. please not the button, along with any other mc's, should not be on your "actions" layer. try it, it will work.
                        • 9. Re: Multi event button
                          mattypee Level 1
                          You were right I followed your instructions and it did work. Only problem now I keep getting a "Flash Player Security Settings" dialog box when the browser tries to go to cnn.com.

                          Not sure what to do.... I can go through the setting to allow the SWF file access to use the internet, but I would like my clients to just be able to "cnn.com"

                          Any ideas...

                          Thanks,
                          Mattypee
                          • 10. Re: Multi event button
                            mattypee Level 1
                            Has anybody have any suggestions....?

                            Thanks,
                            Mattypee
                            • 11. Re: Multi event button
                              Damon Edwards Level 3
                              are you testing this locally? upload to server then test.