Each SWF really should stop its own audio and clean up.  Trying to clean up on 
a SWFs behalf is likely a maintenance issue.

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of djepyon
Sent: Wednesday, September 10, 2008 8:01 AM
To: [email protected]
Subject: [flexcoders] Re: SWFLoader unloading, whats the trick?


Alex thanks for the additional info.

swfloader.content.stop() prior to setting a new source in this case
managed to stop the next swf at the beginning once it loaded. Not sure
why this happened.

I did a bit of testing here and as far as I can tell when a
MovieClip's loaderInfo dispatches an Event.UNLOAD the MovieClip itself
has already been de-referenced.

The timeline audio continues to play however. I've managed to fix this
problem (although this seems a bit of a hack) by calling
SoundMixer.stopAll() in the unload handler. I somehow doubt that this
actually deletes the Sound objects that were created so my guess is
that this could cause a big leak if many SWF's with timeline audio
were being loaded over and over. Perhaps the same problem would
persist even with SWF' with manually instantiated audio?

Here's my quick fix.

MovieClip(event.target.content).loaderInfo.addEventListener(Event.UNLOAD,
unloadHandler);

private function unloadHandler(event:Event) : void {

SoundMixer.stopAll();

}

--- In [email protected]<mailto:flexcoders%40yahoogroups.com>, Alex 
Harui <[EMAIL PROTECTED]> wrote:
>
> I haven't used this event to shut down a movie, so I don't have
examples, but I think the recommended pattern is that the loaded SWF
is supposed to listen for the UNLOAD event on its loaderInfo. If the
main app is listening, then you're probably right that it is too late.
Of course, if you're about to set the SWFLoader's source you can
certainly call swfloader.content.stop() beforehand, but I think stop()
doesn't stop Audio/Video, just the frame timeline. You'll have to
have access to the loaded SWFs Sound instances which is why it is
"better" if the loaded SWF cleans up after itself.
>
> From: [email protected]<mailto:flexcoders%40yahoogroups.com> 
> [mailto:[email protected]<mailto:flexcoders%40yahoogroups.com>]
On Behalf Of djepyon
> Sent: Tuesday, September 09, 2008 8:35 PM
> To: [email protected]<mailto:flexcoders%40yahoogroups.com>
> Subject: [flexcoders] Re: SWFLoader unloading, whats the trick?
>
>
> Thanks guys. The feedback I get on here is always great.
>
> I was able to listen for UNLOAD on the SWFLoader. I tried a
> MovieClip(event.target.content).stop() but it seems that its already
> disappeared at this point and throws a null object reference error.
>
> Listening on the content object didn't trigger the event handler.
> Would it be better to use REMOVED or REMOVED_FROM_STAGE for this?
>
> Maybe I could get some sample code?
>
> --- In
[email protected]<mailto:flexcoders%40yahoogroups.com><mailto:flexcoders%40yahoogroups.com>,
 Alex
Harui <aharui@> wrote:
> >
> > The SWFLoader unloads the SWF which just de-references the SWF bytes
> but does not clear references to objects created by code in that SWF
> which might be referenced by the player or other code, including
> Timers, Video, Audio, player events, etc.
> >
> > In FP10, there is a new unloadAndStop method that will supposedly
> clear this stuff out, but short of that, the child SWF should listen
> for an UNLOAD event and stop Audio and do other cleanup.
> >
> > From:
[email protected]<mailto:flexcoders%40yahoogroups.com><mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected]<mailto:flexcoders%40yahoogroups.com><mailto:flexcoders%40yahoogroups.com>]
> On Behalf Of Josh McDonald
> > Sent: Tuesday, September 09, 2008 4:48 PM
> > To: 
> > [email protected]<mailto:flexcoders%40yahoogroups.com><mailto:flexcoders%40yahoogroups.com>
> > Subject: Re: [flexcoders] SWFLoader unloading, whats the trick?
> >
> > IIRC, any loaded SWF that's no longer referenced will be garbage
> collected (and fairly quickly from my experience), but streaming audio
> (or video) is still referenced by the player so it doesn't go anywhere.
> >
> > -Josh
> > On Wed, Sep 10, 2008 at 9:40 AM, djepyon <ian@<mailto:ian@>>
> wrote:
> > Does SWFLoader unload itself when you set a new source path? Then why
> > does timeline audio thats set to "stream" in the swf still continue to
> > play? Can give me the skinny on properly unloading a SWFLoader? Thx.
> >
> >
> > ------------------------------------
> >
> > --
> > Flexcoders Mailing List
> > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
> Links
> >
> >
> >
> >
> >
> > --
> > "Therefore, send not to know For whom the bell tolls. It tolls for
> thee."
> >
> > http://flex.joshmcdonald.info/
> >
> > :: Josh 'G-Funk' McDonald
> > :: 0437 221 380 :: josh@<mailto:josh@>
> >
>

Reply via email to