ActionScript 3.0 :: Controlling Sound From A Separate Class
Apr 7, 2009Is it possible to start and stop a sound file from a separate class? In the first class, "House", I have called the MP3 using the following:
[Code]....
Is it possible to start and stop a sound file from a separate class? In the first class, "House", I have called the MP3 using the following:
[Code]....
Is it possible to start and stop a sound file from a separate class?In the first class, "House", I have called the MP3 using the following:
Code:
public var mySoundReq:URLRequest = new URLRequest("tune.mp3");
public var mySound:Sound = new Sound();
[code]......
I need to allow users to preview audio files for purchasing. I have CF pages that return records form a SQL database. Each record contains the same swf file however, each swf file points to a different mp3 for previews of different audio examples. So far, everything is working fine. My problem is that I need to be able to stop the sound from one swf when I click to play a second swf .The only solutions I see in Flash forums deal with loaded swf files. These are not loaded files they are separate files within a page. The question is: How do control one swf from another swf in the same page.The following items have not worked: soundChannel.stop();,soundMixer.stopAll()
View 2 RepliesI have been at this for about 19 hours straight! I am going to go to bed immediately after this post, but for crying out loud, I have NEVER had this problem before today! Before anyone reads ahead and says 'you have to attach your sound object to a completely separate mc to be able to control it independently from all other sound/root volumes.' see if the following code accomplishes just that:
[Code]...
I'm laying out my code differently for my latest project. I am making a game, and I am keeping the Flash API stuff in a seperate class from the game logic.It's an aproach I've never tried before, and it's made me realize just how little I understand good OOP design.
what I'm trying to acomplish is this:
the Game class contains the step by step program flow of the game. it makes calls to a GameUtils class and DrawEngine class, these other classes have the Flash API stuff in themSo what is the best way to get the game class to control the other 2?
currently I have my program flow like this:
1. display splash image
2. add 'play' button
3. recieve click from button -->
[code]....
a more specific issue comes up at step 3: ..how do I have the game class progress without using a listener?I'm thinking of creating a method of the Game class that simply increments a step counter of a switch/case statement and keeping each step of my program flow in each case.
I'm having some trouble with the attached file, I've tried lots of things but just can't seem to control the movie clip. On click on 'Detailing' from the landing page a new slide *slides onto the stage 'content3'. Within this I have added a separate graphic with a tween 'gr_detailcopytest'. I want it to start only when it lands within the main stage's masked area. I also want the tween to stop too after its played out. I have tried adding a stop action at the end of the tween but this stops the tween altogether - Furthermore, when I click on another menu item and go back to 'Detailing' I want the tween to start again.
View 6 RepliesMy Website opens, its written in HTML... There is a "Navigation" FLash at the top of the page which opens up HTML documents into the "Main Frame" below.Ok now... When the Website first loads up, In the Main frame of the page I want a flash swf to play as an intro to the website (Its a band website). Once the (intro) Swf ends I want it to tell the Navigation Flash Menu Swf to go ahead and show the buttons so people can navigate.Thats my first problem, or task to solve.2nd... If it is possible to control Swf's from an external one it must be possible to preload them aswell right? So what I want to do, is the site to load up... and all the preloading done from the Navigation Swf to account for both Swfs (Intro and Navigation)
View 2 RepliesOne thing bothers me when I visited one site. I noticed that the sound is in a separate swf, how did they do that? [URL]
View 2 RepliesI've been searching around trying to work this out for a while now. There's been various ideas popping up, like dispatchEvent etc but nothing that seems to be a clear, simple way of doing this.What I'm trying to do is call a function from a class seperate (but in the same folder as) my document class.Specifically, I want to 'spawn' an object and run a function within that object's class from my Main.as.The snippet I have at the moment is as follows;
In Main.as:
var object:class_Object = new class_Object();
object.spawn();
[code].....
I know it has been done in Madness Interactive, which I did check up on and looked through the code and found nothing, as well as Googled a bunch of stuff, and still nothing.
View 3 RepliesI've been hitting dead ends while programming lately all over, and I finally came to the realization all the code I have that is broken is because I don't know how to interact with instances of one class from within another. Here's the gist of what I am trying to do:
if(this.hitTestObject(targetClip)){
trace("hit!");
}
The problem is, if I address a single instance that is on the canvas, I get "access to undefined property targetClip", even though the document class can interact with it fine. If I target the class file of targetClip, I get "Implicit coercion of a value of type Class to an unrelated type flash.display:DisplayObject". It isn't just a problem with hitTest either, I'm having this problem with other actions, so there is some basic syntax I'm failing to comprehend.
I am facing a problem with multiple sound file in one flash file. I have added a background music in my flash and on one of the page, I have published a video. However both sound files are clashing with each other. If I will do stopAllsounds(); on the video frame then while moving on next section the sounds still remains stop.
View 1 RepliesI'm new to Flash AS3. I started making a game and I am a bit confused. Let's assume that I want to create a game that has multiple levels/modes, how can I do this in an object orientated way?
When i create games in other languages e.g. XNA C#, i create a separate class then create an object of that class within the main class and run the game based on a simple statement.
[Code]...
I wanted to have this Zombie Penguin enemy use a walk sound (it would be odd if he moved and was silent) but because it is initializing the whole world, simply coding the sound into his animation state won't work because it will play the sound for every existing Zombie Penguin in the world, not just the one on the screen.
Now I've tried to get around this problem by using a SoundManager class [URL] to load and play/pause the sound when necessary. I've got this working by placing a movieclip above the world and hittesting everything and when it finds a Zombie Penguin activates the SFX. If it finds the enemy and you leave the room or kill the enemy (basically any way it is removed from the screen) it will pause the sound (not stop) and then unpause if you go back/find another instance of that enemy.
The problem is, though, that if I STUN the enemy (not kill it) it plays it's dizzy animation (which consists of hit sitting down with stars spinning around it's head) the walking SFX continues to play as the enemy is still on the screen.Now in the Zombie Penguins .as file it has a boolean that for being stunned or not (bStunned), and a function (public function getZPStun():Boolean -- returns bStunned). this bStunned boolean is set to a default of false.I figure that I just have to reference that somewhere in the following code, but I'm not sure where. The Zombie Penguin's .as is ZPEnemy, so I'm calling it like so:
ZPEnemy.getInstance().getZPStun()
I've tried calling it as part of an if statement a in a number of placesin hopes that calling it will relate the current state of the bStunned boolean, but I can't seem to get it to work.
Code:
var bNotPenguin = true;
for(var i = 0; i<this.numChildren; i++) //** Sound Manager Coding (May 15)
{
[code]....
I've created a small application that links various Sound Clips to corresponding Sound variables, and the individual start and stop commands work fine. However, when I try altering the volume, the controls affect all the sounds in the movie. I'd like to refrain from creating separate SWF files to represent each sound, but I will if I have to.
View 1 RepliesI used a template from a flash template website but I just realized that the background control was written to control all sounds, now all the video sound and seperate sounds objects stop when I click on this one button. This is the code below that I found on the button. There are others also.
[Code].....
I have a child SWF with a linked sound that I want to control from the mother SWF. In the child SWF there are different linked sounds in separat frames. The "Control system" is in the mother SWF.
View 8 RepliesI'm trynig to control an sound of a external SWF but I can't seem to get it right,here is the code i'm using to import the sound
mport flash.media.Sound;import flash.net.URLRequest;import flash.display.Sprite;import flash.media.SoundChannel;import flash.events.Event;import flash.events.MouseEvent;var _som1:Sound;var _channel1:SoundChannel;var _playing1:Boolean = false;var[code]...
I'm doing a project that I have to use scenes in, I have a sound object that i want to be able to control in all scenes. I set up global variables for the sound object and a boolean to check if the sounds currently playing like this :
PHP Code:
_global.sound1= new Sound();
_global.sound1.attachSound("song");
_global.soundplaying = 0;
In each scene I have two buttons a stop and a play button, Heres my code for play:
PHP Code:
if(!_global.soundplaying){
_global.sound1.start();
_global.soundplaying = 1;
}
And stop:
PHP Code:
_global.stewielaugh.stop();
_global.soundplaying = 0;
Doesn't seem to work, if I press play in scene one and go to scene 2 and then return to scene one the sound can be played again on top of the already playing sound object.
I'm making an application and I can't seem to find a way to control my sound of an external SWF(SWF2) from the main one(SWF1).Here is the code I'm using to control the timeline of external SWF that is placed inside of the main movie
Code:
var loadAnimBox:Loader = new Loader();
var vid_mc:MovieClip;
function startLoading():void {
[code]....
I have a button on my main scene which creates the varaiable "soundoff", then if one of the placed swf's when loaded detect the variable it stops all sounds,
if(soundoff == true){
stopAllSounds();
This works fine but does not target sounds placed in movieclips in the loaded swf's timeline. I've tried targeting them with the _root. command and using linkage but I can only stop the sound in the main timeline level.
I have a loaded SWF file in _level1 that has audio in the timeline. I am trying to control the volume of this loaded SWF with a 'mute' button in the main SWF file. On the first frame I'm using the code:
my_sound = new Sound(_level1);
and then on the button script I have:
mute_btn.onPress = function(){
my_sound.setVolue(0);//mute volume
}
but it's not working. Is the new Sound(_level1) not valid?
I am having trouble controlling sound instance on the main timeline from with a movieclip.
On the main timeline contains the following code:
root.createEmptyMovieClip("beat_mc", 100);
beat = new Sound("beat_mc");
[Code]....
The main timeline will render the sound at the volume 10 value. However, I anticipated the volume to be set at a 100 from the Jukebox's controller.
It would seem logical that the jukebox code should respond to the instance "beat", but it doesn't.
I now changed my movie up to where a "empty movie clip" is created that plays songs on maintime of movie. However, I still want to have a tab where it says "sound controls" be automated so that when users roll over it, it slides in and shows controls for sounds instead of them always being present. This roll over effect is the simple AS:
Code:
soundtab.onRollOver = over;
soundtab.onRollOut = out;
[code].....
I now have my sound clip working in a container swf (level0).. Can I control this sound clip from other levels that have been loaded into level 1 from the container swf?Would it be something like
PHP Code:
_level0.mysound.setVolume(30);
If so, where do I name the music 'mysound'? I have simply dragged the music into the main timeline. Would it be better if I loaded it externally?
On my Main SWF i have a Flv that has no sound
[Code]...
When i play the Main SWF the volume is 0 which is good, But when i click on the button to load the 2nd SWF the sound comes on for both FLV's when i want the 1st FLV to stay at 0 volume and the 2nd FLV to play with sound at 100.
I am trying to create a movie that has 3 different background sound loops for the user to choose from as well as an on/off button.I followed one of the Kirupa tutorials which enabled me to create 3 different buttons that linked to the 3 sound loops in my library. The problem is that I don't know the actionscript required to stop whatever clip is playing and play the newly selected background sound chosen by the user.Also I am trying to have one of the loops playing when the movie starts as a default, and also to have a mute button
View 1 RepliesI have a loaded SWF file in _level1 that has audio in the timeline. I am trying to control the volume of this loaded SWF with a 'mute' button in the main SWF file. On the first frame I'm using the code:
my_sound = new Sound(_level1);
and then on the button script I have:
mute_btn.onPress = function(){
my_sound.setVolue(0);//mute volume
}
but it's not working. Is the new Sound(_level1) not valid?
I've am trying to create a sound control to control the sound of an imported FLV file. The problem is like this. I recorded a video using a video camera and than using the iMovie, I've converted the movie to QuickTime format. Than I use Sorenson Squeeze for Flash MX to compress the video. I manage to compress the files into FLV format and than imported it to my Flash file. Now I want to add a sound control to the movie to control the volume.
View 2 Repliesi've discovered that the only way to sync loops adequately in flash is to put them together on the timeline.
is there any way to change the volume of each layer with actionscript? i'd like to dynamically mix between loops.