A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: different sounds to same button

  1. #1
    Member
    Join Date
    Aug 2000
    Posts
    66
    okay, i have taken too much time off since i last worked on a project in flash. it seems to me that i shouldn't have to create the same button over and over to give it different sounds. for instance, let's say i have 20 questions on a test. each question is on a different screen (frame). i have a little speaker icon next to the question in case a person cannot read but wants to hear the question. the little icon is the same on all 20 questions. do i have to create 20 copies of this button so that i can assign a different sound to each button for each question?

    also, will this increase the file size of the final swf file?

  2. #2
    Challenge the Conventional
    Join Date
    Jun 2000
    Posts
    775
    nope .. if you use the sound object you can use an instance of the button on each scene to call the required sound you want.

    have you used the souns object b4 ?

    P

  3. #3
    Member
    Join Date
    Aug 2000
    Posts
    66
    Originally posted by Peter H

    have you used the souns object b4 ?

    P [/B]
    nope. as complicated as some of my actionscripting is...i still feel like a newby when it comes to some of flash's features. i used flash 3 quite a bit, but have only played with things sparingly since then. i'll look into sound objects...any advice?

  4. #4

    file set up

    hi,

    as long as you have a generic symbol for the button (movieclip that has a invisible button, or just a button), duplicate that 20 times shouldn't make the file size that much larger. If you want to use just one button symbol to control the goto frame action and play different sound, you can set up a conditional statement something like:


    Var currentScreen = ""
    this variable should detect whatever your currentFrame is of where the question sits, then a condition statement as follow for the button to advance the time line:

    on (press)
    if (movielcipName.currentframe == (currentScreen)) {
    questionMC.gotoAndPlay (nextframe);
    soundMC.gotoAndPlay (frame number associated with this frame)
    }
    else {blah blah blah}

    this is just a quick suggestion, but something along that line should work. Hope this will give you some idea...

  5. #5
    Member
    Join Date
    Aug 2000
    Posts
    66
    thanks funk-man. i hadn't thought of using the scripting to do it. duh! that is much easier for me than trying to figure out some of the other features most people find easy. cool!

    my button is uses gradients and some intricacy. better to not duplicate it the since it appears exactly 48 times.

    thanks for the example. makes sense. ;-)

  6. #6
    Challenge the Conventional
    Join Date
    Jun 2000
    Posts
    775
    whilst funkyBudda's example does work, you might fins you have better results this way.

    Using the soundObject means we have much greater control over sound. The major deofference is though, there is no need to bring sound onto the timeline. It's all controlled through scripting.

    Firstly we need to identify the sound we want to use in the library. Right-Click [CTRL click MAc] on the sound a select linkage. Select the second option 'Export this symbol' and enter a name in the identifier. for now lets call it soundOne. OK all of this.

    Now we need to create a new soundObject. We need to create a new unique soundObject for each sound we want to use. To do this, enter the following code on the first frame of you movie.

    mysound1 = new sound(this);
    // This creates the new sound object called mysound
    mysound1.attachSound("soundOne");
    // This attached our sound in the library we called soundOne
    mysound1.setVolume(100);
    // This sets the volume of our mysound to 100%

    If you set up seperate sound objects for each sound you need all that is then required is the command to call each sound as you need it. for example mySound2, mySound3, etc...

    On the speaker button the place the following.

    on (release) {
    mysound1.start(0,1);
    }

    // This starts the sound. The 0 represent the staqrt offset of the play back. setting this to 5 for example starts the sound playing 5 seconds into the sound. The 1 represents the number of times the sound should loop.

    Just change the number of the mySoundx dependant on wich scene you in.

    Hope this is clear

    P



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