 |
Featured jobs
Featured template
View more templates
 |
 |


Next 5
A better control over sound Object
 |
 |
// an empty mc linkage must exist in library
_root.attachMovie( "empty", "empty", 100 )
function SoundObj()
{
this.count = 0;
this.addSound = addSound
}
function addSound(sound_id)
{
_root.empty.duplicateMovieClip(sound_id,this.count);
obj = _root[sound_id];
obj.sound = new Sound(obj);
obj.sound.attachSound(sound_id);
this.count+=1;
}
XSound = new SoundObj();
// Usage
// XSound.addSound( linkage_name_of_the_sound )
// after that a new object is created names as the
// linkage_name_of_the_sound
// this objcet can accept diferents values
// for the ex: .setVolume(x)
// that only affects to it and not to
// all sounds
//
XSound.addSound("track1");
XSound.addSound("track2");
// to start track1
// track1.sound.start()
Posted by: Pedro Aguilar | website
http://www.xperiments.com
|
 |
 |
 |
A fader prototype
 |
 |
// Credit to Michael Tapson (earlier post) for most of the development of this
// script. I have modified it to be a part of the Sound object's prototype,
// and thus, it will work with any sound clip you have.
Sound.prototype.fadeup = function ( fadespeed, maxLevel ) {
var SndIntervalID;
clearInterval ( SndIntervalID );
SndIntervalID = setInterval ( this, "upOne", fadespeed, maxLevel );
// BUMP VOLUME UP
Sound.prototype.upOne = function ( maxLevel ) {
varSnd = this.getVolume();
if ( varSnd < maxLevel ){
this.setVolume ( varSnd + 1 );
}else{
clearInterval ( SndIntervalID );
}
updateAfterEvent();
}
}
Sound.prototype.fadedown = function ( fadespeed, minLevel ) {
var SndIntervalID;
clearInterval ( SndIntervalID );
SndIntervalID = setInterval ( this, "downOne", fadespeed, minLevel );
// BUMP VOLUME DOWN
Sound.prototype.downOne = function ( minLevel ) {
varSnd = this.getVolume();
if (varSnd > minLevel){
this.setVolume ( varSnd - 1 );
}else{
clearInterval ( SndIntervalID );
}
updateAfterEvent();
}
}
// Usage:
// mySound.fadeDown(fadeSpeed, minLevel)
// mysound.fadeUp(fadeSpeed, maxLevel)
//
// Parameters:
// fadeSpeed - A number higher than 1 that determines the length of
// time in which the sound will fade in or out. The
// higher the number, the longer the fade.
// minLevel - A number between 0 and 100. This is the lowest volume
// to which the volume will fade. (Only in fadeDown)
// maxLevel - A number between 0 and 100. This is the highest volume
// to which the volume will fade. (Only in fadeUp)
//
// Example:
// s = new Sound();
// s.attachSound("linkedSound");
// s.fadeDown(20, 0);
Posted by: J. Tomasino | website
http://www.aloneone.com
|
 |
 |
 |
Attach a sound to a certain event
 |
 |
You could use the sound object as follows:
1) Set your sound up in frame 1:
s = new Sound();
s.attachSound("buzzSound");
2) Place an action that test a condition on an MC:
onClipEvent (enterFrame) {
if (_root.threeOfAKind==true) {
_root.s.start();
} else {
_root.s.stop();
}
}
3) Finally you'll have to set an action that sets 'threeOfAKind' to first true and then back to false. You do this because the action is place in an onClipEvent (enterFrame) so the test is re-initiated every frame. As an example:
on (press) {
_root.threeOfAKind=true;
}
on (release) {
_root.threeOfAKind=false;
}
If you can't manage it with an onClipEvent then place your actions in a control MC.
Posted by: No name | website
http://
|
 |
 |
 |
Attached sounds and the loadMovie action
 |
 |
Attached sounds do not play if the SWF containing the sound is loaded using the loadMovie action.
For example, the following ActionScript attaches and plays a sound asset which has been exported with the linkage name "mySound":
soundContainer = new Sound();
soundContainer.attachSound("mySound");
soundContainer.start();
This script will function properly except when the SWF containing it is loaded into another movie by a loadMovie action. In this case, the loaded movie loses it's connection to the linked sound.
Solution
In the original FLA file, add the keyword 'this' to the new Sound constructor, as follows:
soundContainer = new Sound(this);
soundContainer.attachSound("mySound");
soundContainer.start();
Export a new SWF with this structure. The script will now function properly, regardless of the movie's hierarchical position.
Posted by: No name | website
http://
|
 |
 |
 |
Control Sound with AS,2 text fields& a button:P
 |
 |
s= new Sound(this);s.attachSound("yoursoundslinkagename");
_root.setPan(number);
_root.setVolume(number);
on(press){
s.setPan(Math.random()*100);
}
on(press){
s.setVolume(Math.random()*100);
}
on(press){
s.setVolume(Math.random()*100);
s.setPan(Math.random()*100);
}
on(press){
s.setPan(_root.txt);
}
on(press){
s.setVolume(_root.txt);
}
on(press){
s.setPan(_root.pan);
s.setVolume(_root.volume);
}
Posted by: Alcatraz5 | website
http://www.newgrounds.com
|
 |
 |
 |
Next
5
|  |
Search Entire Site
Advertisements
Latest New Articles
- Set up a simple IIS Server for Flash
by Peter McBride - Day 1 at FITC Toronto 2008
by Anthony Pace - Simple reflection effect with AS2
by Jean André Mas - ActionScript.org Meets Josh Tynjala (aka dr_zeus)
by ActionScript.org Staff - Rapidly Create Online Flash Movies to Help Users Market, Sell and Support Software and Hardware
by Sabrina F
|
 |