ActionScript 3.0 :: SoundManager - Pausing Sound By Referencing Code In Separate File?

May 22, 2009

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]....

View 4 Replies


Similar Posts:


ActionScript 3.0 :: Timeline Code And Separate AS File Code Working Together

Dec 27, 2010

Is there a way to make code on the timeline and code in a separate AS file communicate with each other?I have two buttons, a yes button and a no button.I have a confirm box which is a movie clip. In the movie clip I have the two buttons on it and code so that every time one of the buttons is clicked it runs a function.I have the rest of my code for the movie (so the code to make the confirm box appear) on a separate AS file.Is there a way I can define the functions on the movie clip and run the functions with the separate AS file?

View 7 Replies

ActionScript 2.0 :: Handle Two Separate Sound File?

Feb 9, 2010

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 Replies

Actionscript 3.0 :: Basics Of Papervision3d Tut Code As A Separate As File?

Feb 17, 2009

I've just been following the Basics of Papervision3D tut, which is very good by the way, the only one I've ever managed to get working.And I'd like to write the code as a separate as file, but I'm having a bit of trouble.In the class definition, what should it extend?[code]I tried everything I can think of and looked at other tuts to see what they've done but nothing works.

View 1 Replies

ActionScript 2.0 :: F8 - Attach Sound Object To A Separate Mc To Control Independently From All Other Sound / Root Volumes

Mar 15, 2008

I 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]...

View 2 Replies

ActionScript 2.0 :: Pausing Sound In FMX?

Jan 12, 2004

my problem pertains to Flash MX and pausing .mp3 files I have loaded externally. I have searched this forum, but every useful thread i found references [URL] but that page gives me and http 500 internal server error... ie the site is down.

but my problem is that I need to know if there is a reletively simple (or actually any at all) way to pause a song through a button that i have externally loaded... this is my code so far:

[AS]
Song = new array("tonight.mp3", "when in doubt.mp3", "hey now.mp3");
bgSound = new Sound(this);
bgSound.loadSound(Song[Math.floor(Math.random()*3)], true);
bgSound.start();

[code]...

It looks a little complicated because i have a volume slider in there, as well as loading songs randomly... but what i need to know is how to get the stopB button to pause the song... and the playB button to resume it... right now stopB just stops the song... and playB loads a new one randomly.

View 4 Replies

ActionScript 2.0 :: Pausing A Mp3 Sound

Feb 29, 2004

i am making a music player in flashmx but i don't know how to pause the mp3.

View 4 Replies

ActionScript 2.0 :: Pausing Animation AND Sound?

Aug 29, 2005

Can you pause both animation and sound? I know you can do

on(release){
stop();
stopAllSounds();
}

but you can't start the sounds again after that at the place they were at, like a soundtrack. What is the actionscript (if it exists) for a pause and play buttons that also pause and play the sounds?Imported movies pause sound with stop();, do i have to export an swf with like just the soundfile and put that in? Cause i think that would work but sounds like too much trouble.

View 9 Replies

ActionScript 3.0 :: Pausing & Resume Sound?

Oct 15, 2009

I'm trying to pause and resume play a background sound loop and tweens with the same button

The animation pauses and resumes fine. But when the music resumes, it gets cut-off early, and it doesn't loop anymore.

The code is as follows:

[code]...

View 3 Replies

ActionScript 3.0 :: Pausing And Resuming A Sound Loop?

Dec 3, 2010

So my program starts playing and my background music starts to play and loops...

Actionscript Code:
mySoundChannel = mySound.play(0, int.MAX_VALUE);

but i'd like to be able to pause the background music and then continue looping. this is what i'm doing now after i've stopped the song and acquired it's current position, and am ready to play again...

Actionscript Code:
mySoundChannel = mySound.play(resumePosition, int.MAX_VALUE);

problem is that when it loops, it loops back to the resumePosition (as expected since that's when we told it to start playing from). so how to i resume AND loop starting over at the beginning of the song?

View 3 Replies

ActionScript 2.0 :: Pausing, Resuming Sound Loaded In Mc?

Mar 26, 2010

I haven't found this one yet, plenty about pausing sound, but I have sound loaded into a movie clip so:

Code:
Intro1 = new Sound (soundLoader);
Intro1.loadSound("SndIntro1.mp3", true);

I'd like to get a pause button to stop the animation, get the position of the sound, stop it also, and then clicking the play button will start the animation, and also the sound from the same position it was stopped (in other words resume the sound). Here's my script for the pause button, it's stopping the animation, but still not the sound:

Code:
on (release) {
pauseTime = Intro1_sound.position;
Intro1_sound.stop();
stop();
}

View 3 Replies

IDE :: Image Galleries - Pausing Sound From External SWF

Apr 18, 2010

I am making a set of image galleries which will have looping background music. What are your opinions about the recommended method to bring music in? I am happy with the attachSound and loadSound methods, but wondered whether attaching a soundtrack.swf using loadMovieNum would be better. If so, I only know how to stop and start the music, not pause it and restart where it left off, which is important if I add a narration. Sound Objects seem more versatile because they let you use "position/1000", but from what I have found on the forums I have searched through, I may have to load the swf into a Movieclip or perhaps use _level somewhow?

Here is the code, which works well, but does not "pause" the music, it just stops and starts at the beginning. Code is in the root timeline of my soundControls_mc (play/pause button).
[Flash 8 - AS2]
loadMovieNum("includes/number10.swf", 100);
soundOn = true;
this.onRelease = function() {
if (soundOn == true) {
unloadMovieNum(100);
[Code] .....

View 2 Replies

ActionScript 2.0 :: Pausing And Resuming A Background Sound On One Button?

Sep 14, 2010

I'm having problems with pausing and resuming a background sound on one button. I tried some examples from kennybellew.com tutorials, but it just wont work for me.I have done some button work before (toggling, turning layers on/off etc.), i just never had to deal with sound.

View 9 Replies

ActionScript 3.0 :: Animation Pausing When Lost Focus, But Sound Continues?

Jul 9, 2010

I have an issue with an animation/movie thingy i am making

When the user for example, Switches a tab in firefox or something. The sound on the video will continue to play, but the animation will pause. Leading the animation to become out of sync with the sound.

Is there a way to make the animation continue playing even if the tab has been changed??

View 8 Replies

ActionScript 2.0 :: How To Get Sound In Separate SWF

Mar 29, 2003

One 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 Replies

ActionScript 3.0 :: Separate The Code Into Classes?

Dec 8, 2010

Im currently trying to make an as3 fantasy football application for my uni course, but am finding it hard to seperate the code I have written into classes (which I have no been told is the only accepted method for the marking scheme). So far I have an external XML file containing player names load into a datagrid component, there is then an event listener on the table which loads the player images into their correct positions on a pitch when clicked. I need to write more functionality for it including saving to XML and error handling but feel I need to sort out the classes situation before I continue and it is in for this week.

Code:
import fl.controls.dataGridClasses.DataGridColumn;
import fl.data.DataProvider;
import fl.controls.ScrollPolicy;[code]..............

View 0 Replies

ActionScript 2.0 :: Loading Sound From Separate .SWF?

Dec 5, 2007

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 Replies

ActionScript 3.0 :: Splitting The Code Into Separate Files?

Oct 22, 2010

I'm looking for some help with the following script:

Main Class:

Code:
package {
// Flash Classes
import flash.display.MovieClip;
import flash.events.Event;

[code]....

Now, I'd like to move the blue color coded script to the separate package. When I do that, I've got many reference errors. how the code should look like, when it's in separate package, with all the references to variables that work? And how to call this function from Main class?

View 1 Replies

ActionScript 3.0 :: Controlling Sound From A Separate Class

Apr 7, 2009

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]....

View 1 Replies

ActionScript 3.0 :: Controlling Sound From Separate Class?

Apr 7, 2009

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]......

View 1 Replies

Actionscript 3 :: Flex 3 Referencing Old Files, Will Not Compile Updates To Code

Feb 28, 2012

I am using Flex Builder 3, working on a PC. Everything was working as expected throughout my first day of code updates, but on day 2 Flex started behaving badly.The problem started when I removed a component, and then got an error that it couldn't find the specified component in some accompanying AS3 code. No problem, I updated the reference so it wouldn't look for the old missing component (a form item). When I compiled the project in debugger to check my work, it failed when it got to that part, and gave an error that it couldn't find the component I'd removed. However, my code had fixed the problem, and the error was referencing a line of code that wasn't there any more. I proceeded to change the file around greatly, and even resorted to creating a new file, changing the name of it, and then recompiling it. I did a clean compile as well, rebooted my machine, restarted Flex, but every time it gives an error referencing the bit of code that isn't even there any more. It's as if it's loading a cached project each time (both in debugger and run mode).

For reference, here's the error I'm getting: ReferenceError: Error #1069: Property Winter Cost not found on views.PopupUsage and there is no default value.Well, the file "PopupUsage.mxml" doesn't even exist any more and is not referenced in my project at all, but it's still being referenced by Flex when I compile the files.What can I do to make Flex move on and look at my code?

View 1 Replies

ActionScript 3.0 :: Moving Part Of The Code To Separate Package?

Oct 22, 2010

Main Class:package {// Flash Classesimport flash.display.MovieClip;import flash.events.Event;import flash.display.StageAlign;import [code]........

Now, I'd like to move the script between --- Start --- and --- End --- comments, to the separate package. When I do that, I've got many reference errors. how the code should look like, when it's in separate package, with all the references to variables that work? And how to call this function from Main class?

View 5 Replies

Actionscript 2.0 :: Code For Button On Separate Layer In Timeline?

May 18, 2011

I made a button a stage, and I want the button to take the user to a separate scene that I have named "Biography page" when it is clicked. The thing is, I want all my actions on one specific layer. So I made an instance name for my button, "aboutme". The thing is... I have no idea how to write the code.

[Code]....

View 3 Replies

ActionScript 3.0 :: Display List Referencing - Code No Longer Works And Get An Error?

Jul 16, 2009

I have a container movieclip called cont_mc then inside that I have a series of pins which are called pin1_mc then inside the pins I have a final movie clip the size of the pin head to act as the hit state.You can see what I talking about here: http:[url]... Before I had the pins in the container movie clip I was able to bump them to the top of the display list using this code in the on over function.this.setChildIndex(event.target.parent,this. numChildren-1); Now I have wrapped them in the container mc this code no longer works and I get an error, must be a child of the caller?How can I change this?

View 5 Replies

ActionScript 3.0 :: Pausing An External Mp3 File?

Jul 8, 2009

Right now I am using this code to load an external mp3 file into my website:
 
var url:String = "my file";var urlRequest:URLRequest = new URLRequest(url);var sound:Sound = new Sound();sound.load(urlRequest);sound.play();
 
I am wondering if it is possible to add playback buttons (play, pause, stop) which control this external mp3 file from my site. And what code I would use to do that.

View 12 Replies

ActionScript 3.0 :: Porting Gallery Code From Flash To Separate Class

Mar 26, 2010

I have an xml gallery sort of that works fine when I have the code not as a class, in first frame in Flash. So I decided I wanted to port it into a class and the problem I get is at:
thumb = new Thumbnail(xmlList[i].image);
It expects 0 arguments. How come that line of code works in first frame in flash but not as a class? There is a movieclip in the library called thumb with linkage of Thumbnail.

Below if the code when used in first frame:
PHP Code:
var urlRequest:URLRequest = new URLRequest("pics.xml");
var urlLoader:URLLoader = new URLLoader();
var xml:XML;
var xmlList:XMLList;
urlLoader.load(urlRequest);
[Code] .....

View 4 Replies

ActionScript 3.0 :: Play A Sound File And Show The Progress Of The Sound File Being Played

Mar 16, 2009

I have to play a sound file and show the progress of the sound file being played. I am using import flash.media.Sound; import flash.media.SoundChannel; But the PROGRESS event gives theprogress of loading of file. I want to know of much of the song has been played and how much more is left.

View 3 Replies

ActionScript 2.0 :: Multiple Sounds - Creating Separate SWF Files To Represent Each Sound

Sep 20, 2002

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 Replies

Horizontal Text Scroller Pausing, Getting Txt From External File?

Dec 13, 2010

find a horizontal or vertical message scroll-er that pauses on each message? And pulls the message from a external xml or text file. Trying to make a website news scroll-er that's easy for the owner to edit

View 5 Replies

ActionScript 2.0 - Flash - Export From .fla File Symbol's (frames) To Separate File And Use It

Nov 17, 2011

I am very new to ActionScript. I have a .fla file which contains the AS2 code for the frames. What I need to do is that I have to export this code as a separate file. There may be a separate file(or class file) for each frame code. Is it possible to me do it automatically without losing animation interactivity and functionality? Or is there any other way?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved