Skip to main content
Participating Frequently
October 25, 2013
Answered

Jumping to another Scene without Playing the Sounds AS3

  • October 25, 2013
  • 2 replies
  • 9874 views

I am having a critical issue with sounds in Flash CS6 AS3 , I will make my question very simple.

For Example:

I have 3 Scenes in the Project

"Scene 1"
"Scene 2"
"Scene 3"

I have a Button in "Scene 1" which should take me to "Scene 3" when Clicked.

the Problem is: all Sounds within MovieClips in "Scene 2" Automatically Starts , I am using this code:

btnGoS3.addEventListener(MouseEvent.CLICK , btnGoS3CH);
    function btnGoS3CH (e:MouseEvent) :void
{  
  gotoAndStop
(1,"Scene 3"); 
  
}

I Thought that the above code should take me to "Scene 3" without any problems I don't know why Sounds from "Scene 2" starts while I am not going to "Scene 2" at all

Please provide a simple and clear solution , take in consideration that I have a tremendous amount of movieclips in my real project , so stoping the sound of each movieclip might not be good for me as I have MovieClip inside MovieClip etc.

Thanks in Advance

This topic has been closed for replies.
Correct answer kglad

that's a bug unrelated to scenes.  the same problem occurs in a one scene timeline.

2 replies

Amy Blankenship
Legend
October 25, 2013

What actually happens is that the playhead visits Scene 2, but in such a way that the objects in it are not built correctly. This means that even the Flash Player has no control over those improperly built items--and your code surely has no chance to get control of them. Just make sure your goToAndStop actually visits each scene on the way to your final scene, and this should fix a lot of problems. Also note that your embedded sounds will probably do better set to "stream" rather than "event."

Note that most people don't use scenes these days, but this problem exists even with just using labels.

OzearAuthor
Participating Frequently
October 25, 2013

Thanks kglad and Amy Blankenship for your comments ,

Well there is no chance for improperly , forget my real project just try this :

Create a new flash AS3.0 Project and create three of four Scenes let us create 4 Scene and place sounds in Scenes "2" and "3" , note: Sounds must be in movieClips , and set the sounds what ever you like stream , event or strat/stop and then create button in Scene 1 and let it take you to Scene 4 and see what happens (Sounds in Scene 2 and Scene 3 will start !) [and note that there is no codding in Scene 2 and Scene 3 so nothing is build improperly] , and I am just saying "Scene 1" and "Scene 2" etc , in real projects people use to name their Scenes.

So now should we consider this as a bug or what ?

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
October 25, 2013

that's a bug unrelated to scenes.  the same problem occurs in a one scene timeline.

kglad
Community Expert
Community Expert
October 25, 2013

change your sounds' sync properties to event.

OzearAuthor
Participating Frequently
October 25, 2013

Well , Thanks for your instant replay .

All of my sounds are already events

I have already tried the following:

1 - Changing sounds to start and adding sound again in the last frame and setting the sync to stop.

2 - Using the SoundMixer.stopAll(); code.

3 - Using the currentFrame.Name within all movieClips where they sould play in the specified scene only , if(MovieClip(root).currentFrame.name == "Scene 2") { Play(); }else { stop();}.

4 - Creating a boolean variable in my class file and setting it's value to false by default and then in my button which takes my to Scene 3 change my variable to true and let the button take me to Scene 2 , and in Scene frame load i use this if statement if(isGothrough == true) { gotoAndStop(1,"Scene 3")} , so it first goes to Scene 2 and directly the Scene 3 and in this Case YES Sounds of Scene 2 does not plays in Scene 3 however I can't use this at all , for example I have a lot of buttons Like This

Button 1 >> Takes me to Scene 2

Button 2 >> Takes me to Scene 3

Button 3 >> Takes me to Scene 4

So I can't go to all the Scenes to stop there sound ,

I simply want to go to any Scene without playing anything from the rest

I need to jump to Scene directly

in my real project I have a lot and a lot of movieClips , Scenes etc.

so creating a class for each movieClip and then reducing that movieClips' volume level to 0 is not a real solution , I want something simple ,

I want to jump without playing anything from Scenes in between.


kglad
Community Expert
Community Expert
October 25, 2013

you must have the sound in scene 3.

to test create a new scene and change your goto.