A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: Attaching sound to a variable...

  1. #1
    Senior Member
    Join Date
    May 2006
    Posts
    119

    Attaching sound to a variable...

    Im wondering how you go about attaching a sound to a variable. Im probably being very vague in this question sorry... but any help would be appreciated.

    Thanks

    Mark

  2. #2
    Member
    Join Date
    Feb 2006
    Posts
    77
    Code:
     _root.createEmptyMovieClip("my_mc",_root.getNextHighestDepth());
    var mySound:Sound=new Sound(_root.my_mc);
    
    mySound.attachSound("sound_id");
    mySound.setVolume(100);
    mySound.start();
    You can skip the parameter when initializing a new Sound object but if so you cannot ajust volumn of the sound if there are several sounds on stage.

    the sound_id is the identifier (right click the sound and choose linkage,enter the indentifier)

  3. #3
    Senior Member
    Join Date
    May 2006
    Posts
    119
    Thank you for that.

    I do however have another question, I guess I should have elaborated more on my original question.
    I want to create this variable when a startDrag is initiated. ultimatly im trying to pass (push?) this variable to an array when it is dropped onto a droptarget. then a for loop to play off all the sounds sequencially.

    any thoughts on how I could use what you just taught me in the manner I am trying for?

    Thank you vey much

    take a look at the fla. its very dumbbed down due to its original size, but it may help.
    (ps. as of now, all my drag and drop script are on the buttons....*i dont script well...)
    Attached Files Attached Files

  4. #4
    Member
    Join Date
    Feb 2006
    Posts
    77
    I woner if this is what you are trying to accomplish.See attach file

    P/x:I notice that u use flashmx 2004.I use flash 8.
    Attached Files Attached Files

  5. #5
    Senior Member
    Join Date
    May 2006
    Posts
    119

    Thanks!!

    well, I will be honest, I could only use the .swf, I can not open the .fla...
    but from what I have seen I think all the component are there that I am looking for. would it be possible to save that .fla down to mx2004? then I could take a long look on what is happening and if I can change it to the way I want it.


    Thank you so much for taking yout time to do these things for me!

  6. #6
    Member
    Join Date
    Feb 2006
    Posts
    77
    Unfortunately I'm quite busy at the moment.You can try downloading a trial version of flash 8 and convert it to 2004mx version yourself

  7. #7
    Senior Member
    Join Date
    May 2006
    Posts
    119

    I got it

    I was able to get the .fla....kinda round about way though, I put it onto my server then decompiled it with *******....
    Im going to look through it now.

    again, thank you very much!!

  8. #8
    Senior Member
    Join Date
    May 2006
    Posts
    119
    after reviewing the .fla that you so kindly made for me, im sorry to say but it is not what I had in mind. It may be a little deciving from my .fla because I had to really trim it down, but there are about 50 of those word tiles. Im tring to make a general drop target that reads a variable which is associated to the word tile, this variable is then in turn written into an array which can be played by a button. here is what I have.

    //the variable to be passed
    on (press) {
    startDrag(tile_i);
    this = tile;
    //tileSound = new Sound();
    //tileSound.attachSound("I");
    tile.attachSound("I");
    }
    on (release) {
    stopDrag();
    if (tile_i._droptarget == tile_1.DropZone)
    trace("test");
    soundSeq.push("tile");
    }

    --------------------------------------------------------
    //the array to write to

    soundSeq = Array();
    _root.button.onRelease = function() {
    for (z=0; z<soundSeq; ++z) {
    play();
    }
    };


    thanks for any help!

  9. #9
    Member
    Join Date
    Feb 2006
    Posts
    77
    If you try to add sound to an Array i am afraid it will become more complex since in a for loop, all the sound will start at the same time (they actually started sequeantially but human ear cannot recognize) .So you sentence will not be whole.

    So just describe your goal more clearly.What you are really trying to do?

  10. #10
    Senior Member
    Join Date
    May 2006
    Posts
    119
    OK, sorry my end goal may have not been described clearly.

    here it is.
    I want a droptarget area to able to play in a seqential order any of the word tiles I place on it.
    I am thinking now it may be better to devide my droptarget into areas but the other problem is that it is going to be completly up to the user what goes into the droptargets, they will be able to choose from up to 100 different words. I have included a new .fla that has additional word tiles so you can get a better idea, I also wrote a few descriptions onto the stage its self, so please take a look.

    I must say that the .fla you provided me was amazing, I think it has potential but to be honest, I could't undertand what was going on in the code..(-_-,)

    once again, thanks for your help!
    Attached Files Attached Files

  11. #11
    Member
    Join Date
    Feb 2006
    Posts
    77
    Sorry I'm alittle busy now.I'll look into it tomorrow.

  12. #12
    Senior Member
    Join Date
    May 2006
    Posts
    119
    Thanks!
    Actually this has caused me to study much more scripting.
    I thought of another possibility.
    If I were to devide the droptarget into zones so that there is only one sound pushed to the array, would it be easier to play the seperate from eachother, say of example, do a for loop then a delay then the next for loop...
    or would that be harder?
    Just a thought that I am looking into aswell.

    Thanks again

  13. #13
    Member
    Join Date
    Feb 2006
    Posts
    77
    That's what I tried at first but after that I decide to add an event to the Sound,when it finish playing.It will play the next (if that word has been plcaed correctly)

  14. #14
    Senior Member
    Join Date
    May 2006
    Posts
    119
    I see, Thats pretty much what Im looking to do, except without having to have words in the "right" place. (so close I can smell it)
    Im also wondering what the text box and button on the the first frame? I ll take a breeze through your code and see if I can find what to change.

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