質問

The timeline of my child swf, there are layers with specific sound files in them to be in sync with my animation. Now the problem arises when I try to import this swf into my main flash website using a loader and the sound will continuously play everytime the button is clicked in the parent. My question is how do I get the sound to completely clear itself and restart from frame 0 of the child swf upon every click of the button that loads the child into the loader within the parent.

var myLoader:Loader = new Loader();// create a new instance of the Loader class
var project1:URLRequest=new URLRequest("Projects/Q1/Flash_Projects/Greeting_Card/GreetingCard.swf");
var project2:URLRequest=new URLRequest("Projects/Q1/Flash_Projects/Landscape/Landscape.swf");
var project3:URLRequest=new URLRequest("Projects/Q1/Flash_Projects/SpaceInvadersTribute/Main.swf");
var project4:URLRequest=new URLRequest("Projects/Q1/Flash_Projects/RandomImageProducer/RndImgProd.swf");
//var project5:URLRequest = new URLRequest("Projects/Q1/Flash_Projects/Tutorial/Main.swf");
var project6:URLRequest=new URLRequest("Projects/Q1/Flash_Projects/Soundboard/Main.swf");

btnQ1P1.addEventListener(MouseEvent.CLICK,Greeting);
btnQ1P2.addEventListener(MouseEvent.CLICK,landscape);
btnQ1P3.addEventListener(MouseEvent.CLICK, tribute);
btnQ1P4.addEventListener(MouseEvent.CLICK, slideshow);
//btnQ1P5.addEventListener(MouseEvent.CLICK, tutorial);
btnQ1P6.addEventListener(MouseEvent.CLICK, soundboard);

addChild(myLoader);

function Greeting(event:MouseEvent):void {
    SoundMixer.stopAll();
    myLoader.load(project1);
    myLoader.x=550;
    myLoader.y=130;
}
//Errors with Sound clips
function landscape(event:MouseEvent):void {
    SoundMixer.stopAll();
    myLoader.load(project2);
    myLoader.x=440;
    myLoader.y=130;
}

function tribute(event:MouseEvent):void {
    SoundMixer.stopAll();
    myLoader.load(project3);
    myLoader.x=550;
    myLoader.y=170;
}
//Errors with slideshow Code!
function slideshow(event:MouseEvent):void {
    SoundMixer.stopAll();
    myLoader.load(project4);
    myLoader.x=530;
    myLoader.y=130;
}
//function tutorial(event:MouseEvent):void{
//SoundMixer.stopAll();
//myLoader.unload();
//myLoader.load(project5);
//myLoader.x = 440;
//myLoader.y = 130;
//}

function soundboard(event:MouseEvent):void {
    SoundMixer.stopAll();
    myLoader.load(project6);
    myLoader.x=550;
    myLoader.y=130;
}
役に立ちましたか?

解決

I had this same problem.

You need to change the sound from "Event" to "Stream". In Flash Professional, this can be accessed from the properties tab of the sound on the timeline. Click on the sound, and then go to the Properties tab and change the type from Event to Stream.

Now, the sound will stop when the timeline is stopped.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top