Jump to content
Search Community

sound keeps playing after removing swf

vdheyning test
Moderator Tag

Recommended Posts

Re: removing swf sound

 

Post by sebastianC. » Wed Oct 06, 2010 1:13 pm

 

Hi Jack, I did read the posting by sebastian, but I'm afraid I don't quite get your solution, I tried pasting your code everywhere without any success, I'm sorry my as knowledge is just not good enough to just get it,

I am attaching the fla file and the swf file that I'm trying to load. The sound lives on the timeline of the ACE.swf, I had hoped that putting it there rather than loading it it would solve the problem but it didn't .

One thing I did find out though that your loader won't load swfs that have pre-loaders! That took me hours to figure out and it's probably a no brainer to every one else out there...:)

 

As always, thank you very much for all your efforts,

Fam

 

here's the code, I was hoping the queue2.unload(); would stop the sound, I do get the garbage removal principle, but I don't know how to make it happen...

 

 

 

var queue2:LoaderMax = new LoaderMax({name:"mainQueue"/*, onComplete:completeHandler, , onProgress:progressHandleronError:errorHandler*/});

queue2.append( new SWFLoader("mK15.swf", {name:"mainClip", estimatedBytes:3000, container:flash_mc0, autoPlay:false}) );

 

 

 

flash0.addEventListener(MouseEvent.CLICK, getFlashMC0);

function getFlashMC0(event:MouseEvent):void {

TweenLite.to(flash_mc0, 1, {x:80, alpha:1});

TweenLite.to(close_btn, 1, {alpha:1});

queue2.load();

}

 

close_btn.addEventListener(MouseEvent.CLICK, closeWindow);

function closeWindow(event:MouseEvent):void {

 

TweenLite.to(close_btn, 1, {alpha:0});

TweenLite.to(flash_mc0, 1, {x:-773, onComplete:unload_mc});

function unload_mc():void {

queue2.unload();}

}

Link to comment
Share on other sites

I fixed it all by myself!

(well, with copy paste and the help of numerous forums)

 

this is what I did:

 

in the close button function, I added

the following:

 

flash.media.SoundMixer.stopAll();

 

like so:

 

close_btn.addEventListener(MouseEvent.CLICK, closeWindow);

function closeWindow(event:MouseEvent):void {

 

TweenLite.to(close_btn, 1, {alpha:0});

TweenLite.to(flash_mc0, 1, {x:-773, onComplete:unload_mc});

 

 

flash.media.SoundMixer.stopAll();

 

function unload_mc():void {

queue2.unload();}

}

 

works like a charm!

and the whole swf and sound all starts playing again when re-loading the movie!

 

If you think/know this is all wrong, please let me know, in the meantime I am happy this works!

 

Thanks again for your great site and great code!

Link to comment
Share on other sites

One thing I did find out though that your loader won't load swfs that have pre-loaders! That took me hours to figure out and it's probably a no brainer to every one else out there...

Not quite sure what you mean - LoaderMax has no such limitations. You can load whatever you want (swfs with preloaders are fine).

 

As far as the audio goes, I'm not quite sure what's going on in your subloaded swf because you didn't include its FLA. It's impossible for LoaderMax to know exactly what you're doing in the subloaded swf in terms of setting up listeners, playing sounds, videos, creating NetStreams, etc. which all should be cleaned up before you unload() the swf in order to make it eligible for garbage collection. It's considered a best practice to create a dispose() or destroy() method on your swf's root that you call first which will manually clean up whatever you need to. Like if you create listeners inside that swf, you'd put code in your dispose() method that removes those listeners. If you play sounds in your sub-swf, you stop them in dispose(). Get the idea?

 

Anyway, glad you solved your problem.

Link to comment
Share on other sites

Thanks Jack!

 

I wish I could be clearer, but I mess with code the trial and error way, without really understanding it.... I know its not ideal, but it works up to a point.

I'll see if I can make a file that's small enough with sound on the timeline so I can send it.

 

I don't know why the movies with pre-loaders don't work, but when I take the first frame with the preloader and its script off, it works, so I just took it off the swf movies I want to load.

 

As the sound goes, I am not adding the sound with actionscript, just dumping it on the timeline, and they are supposed to run for the duration of the movie...so no event really stops it... anyway it works, so I'm not going to fret over it any longer, attached see the pre-loader I was using, maybe that clarifies it,

 

thanks for your reply,

 

Fam

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...