A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: Sound on/off button

  1. #1
    Senior Member
    Join Date
    Jun 2000
    Posts
    3,512

    Sound on/off button

    Does anyone have an example?

    This is from a user:

    I have looked over all the tutorials and I don’t see one for a project I would like to do. I would like to have ONE OFF/ON switch that when my page loads, the music is on and my button says OFF and when you click it the word OFF turns to ON and cuts off the music and then if you click on the ON it will turn the sound back ON. I appreciate your help in this. I have tried inserting my movie clip in the button, but I’m missing the ON connection.

  2. #2
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    To incoorporate this we need a little more info about how you are playing the music in the first place.
    Attached Files Attached Files

  3. #3
    Member
    Join Date
    May 2007
    Posts
    78
    Bret, when I tried opening togglesnd.fun in KM, it bombed giving this error:
    "expected $st$ in CShapeMediaPlayer"

  4. #4
    Junior Member
    Join Date
    Feb 2010
    Posts
    2
    I am using a very small mp3 file and it just loops. I am the user Bob is referring to.

  5. #5
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    looks like corrupt file or something, I'll reupload.
    Are you using a mediaplayer?

    Attached is new upload.
    This uses mediaplayer, works the same for other playing methods.
    Attached Files Attached Files
    Last edited by blanius; 02-08-2010 at 11:14 PM.

  6. #6
    Senior Member
    Join Date
    Jun 2000
    Posts
    3,512
    "Bret, when I tried opening togglesnd.fun in KM, it bombed giving this error:
    "expected $st$ in CShapeMediaPlayer""

    It works OK for me with version 7.4.1

  7. #7
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Yep that was the issue. One of my computers is more up to date than the other.

  8. #8
    Senior Member
    Join Date
    Jun 2000
    Posts
    3,512
    There is something funny going on with the download. From IE, it downloads as a fun file. From Opera, it downloads as a zip file and then you have to change the extension to fun. I don't know how it behaves with other browsers.

  9. #9
    Junior Member
    Join Date
    Feb 2010
    Posts
    2
    Hey guys,
    Can we get back on track to what I was asking? lol I dont want a media player showing, it is STRICKLY a music file on start of site with an on/off switch. You know, like all the High end flash sites has. turn it off and then turn it back on if you want to hear the tune.

  10. #10
    Senior Member
    Join Date
    Jun 2000
    Posts
    3,512
    Maybe there is an easier way but one way is to create a 2 frame movie clip with a button in the first frame which says on and a button in the second frame which says off. The first frame has a stop movie action. The second frame has a stop movie action. The actions for the first button are to stop the sound and go to the second frame. The actions for the second button are to start the sound and go to the first frame.

  11. #11
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Quote Originally Posted by jim12186 View Post
    Hey guys,
    Can we get back on track to what I was asking? lol I dont want a media player showing, it is STRICKLY a music file on start of site with an on/off switch. You know, like all the High end flash sites has. turn it off and then turn it back on if you want to hear the tune.
    BOB, I suspect it's Richard, the zip download thing is a bug in IE.

    Anyway Jim, I did ask in my first post how you where loading the mp3 which you really didn't answer,However either way the concept is the same. Instead of targeting the mediaplayer, just put the name of the sound object instead should work the same, it's just a matter of tracking if it's playing stop and if it's not then play.

    Are you loading the mp3 in the GUI or are you loading it via code? Would help if you can be more specific. You see if you are just loading it in the action panel, I'm not sure how to identify it in code. If you are creating a snd object then you know the name you give it in code.

    And I wasn't aware that all the high end flash sites have mp3's playing as background... Why not use the mini mp3 player component it's tiny and has it's own pause/stop buttons.

    Check this:
    http://bretlanius.com/files/music/togglesnd.html
    and the source is
    http://bretlanius.com/files/music/togglesnd.fun
    Last edited by blanius; 02-09-2010 at 10:01 PM.

  12. #12
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193
    Nevermind...spoke too soon.
    Last edited by etuom; 02-10-2010 at 11:23 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center