flash (macromedia):
Hello there I've made SWF in which, when the user puts their mouse over the movie clip, a rectangle will apear. Now, what I want is the following: as the recangle emerges, for a sound effect to be played at the same time - bearing in mind for it only to happen when the mouse is on the SWF. To put it basically, I want a sound effect to play only on RollOver. How can this be accomplished? All the best, Kristopher (UK).
You need to dynamically load the sound. Here's how to do it with ActionScript 2 (sorry, I haven't got CS3, so perhaps someone else can update it for ActionScript 3): 1) Import the sound into the library 2) In the library, right-click on the sound and choose Linkage 3) Make sure "Export for ActionScript" and "Export in First Frame" are ticked. 4) Give it an identifier name, such as mySound 5) DO NOT put the sound on the timeline. 6) On the main timeline, hopefully you have a separate layer just for ActionScript. If not, create one. 7) Highlight frame 1 of the Actions layer on your timeline, then add this script in the Actions panel: (for this example, I'm calling your movie clip myMC) var rollOverSound:Sound = new Sound(); rollOverSound.attachSound("mySound"); myMC.onRollOver = function(){ rollOverSound.start(0,1); } myMC.onRollOut = function(){ rollOverSound.stop(); }
Hello there, Thank you for your rapid response to my query. Now, I've used the ActionScript you've supplied me with and the sound does play only onRollOver which is what I wanted. However, the rectangle no longer moves. If you would like, I can upload the SWF for your conveinience. All the best, Kristopher (UK).
probably because you have an on(rollOver) on the MovieClip as well as your onRollOver... put whatever is in the on(rollOver) in the onRollOver function.. If I am not correct in assuming this, then post a link to your FLA
Yes, I do have two onRollOvers, one to move a rectangle and the other to play a short sound effects - I'm presuming these are clashing together. Is there any ways around this? All the best, Kristopher (UK).
combine them myMC.onRollOver = function(){ rollOverSound.start(0,1); gotoAndPlay(4); // or whatever, just example
Hello again, I'm sorry, I'm quite confussed as to what you mean. I can use Flash but when it starts to come to some bits of ActionScript I get quite confussed. Could you possibly explain in more detail. Thanks very much. All the best, Kristopher (UK).
Shall I paste all of the ActionScript I have at the moment? Regards,
.. var rollOverSound:Sound = new Sound(); rollOverSound.attachSound("sound"); convo_mc.onRollOver = function () { convo_mc.gotoAndPlay("_over"); rollOverSound.start(0,1); } convo_mc.onRollOut = function () { convo_mc.gotoAndPlay("_out"); rollOverSound.stop(); }
Hello there, You are absoletly a star, it's now working excellently. Thank you very much for your time, efforts and help - it's much appreicated. Thank you very much again. All the best, Kristopher (UK).
Don't see what you're looking for? Try a search.
|