Jump to content
Search Community

Loading swf sometimes causes audio to pop

jtvalles test
Moderator Tag

Recommended Posts

I have an application that uses LoaderMax to load a swf (swf1) with audio. Basically each swf is a chapter in a multi-chapter presentation.

 

When I advance to a chapter (swf2) then return to the previous chapter (swf1) the audio becomes distorted and begins to pop.

 

Is it possible that the previous swf has not been trashed completely?

Link to comment
Share on other sites

I'm not aware of anything SWFLoader-related that would make the audio pop - are you sure you unload() or dispose() the SWFLoader? Also, you should definitely clean up after yourself inside your sub-swf before unloading because SWFLoader/LoaderMax cannot know what code you run inside the swf, so you need to make sure you close any NetStreams, remove event listeners, etc. in order to ensure that nothing would prevent gc of that object. Feel free to post a simple example here if you still need help. 

Link to comment
Share on other sites

Thanks Jack. Here is the code that loads and updates the SWF. Where do I call the dispose() or unload() method to assure gc happens?
 
Also, could this be written as a SWFLoader without a queue? It actually only loads one SWF until the next SWF url is called. I was not able to get it to work with SWFLoader alone.

 

var container:MovieClip = new MovieClip();
var queue:LoaderMax = new LoaderMax({name:"mainQueue", onChildProgress:imageProgressHandler, onComplete:completeHandler});
var mainSWF:ContentDisplay;


function loadSWF(url:String):void {
    
    queue.append( new SWFLoader(url, {name:"main", estimatedBytes:3000, container:this, autoPlay:false}) );
    queue.load();
}


function updateSWF(url:String):void {
    LoaderMax.getLoader("main").url = url;
    queue.load();
}


function imageProgressHandler(event:LoaderEvent):void
{
    TweenLite.to(mc_progress, .1, {alpha:1});
    mc_progress.progressBar_mc.bar_mc.scaleX = event.target.progress;
}


function completeHandler(event:LoaderEvent):void {
    aSlider.addEventListener(SliderEvent.CHANGE, scrubber);
    stage.addEventListener(Event.ENTER_FRAME, trackFrame);
    mainSWF = LoaderMax.getContent("main");
    
    
    addChildAt(mainSWF, 0);
    
    container = LoaderMax.getLoader("main").rawContent;
}
 

 

Link to comment
Share on other sites

I don't see any reason to use a LoaderMax queue, no. And I'm not sure what you're doing with the trackFrame thing or what's happening inside your sub-swf that could prevent gc, but this is my stab at what the code might look like without the queue:

 

var container:MovieClip;
var loader:SWFLoader;
var mainSWF:ContentDisplay;

function loadSWF(url:String):void {
    if (loader != null) {
        loader.dispose();
    }
    TweenLite.to(mc_progress, .1, {alpha:1});
    loader = new SWFLoader(url, {name:"main", estimatedBytes:3000, container:this, autoPlay:false, onUpdate:imageProgressHandler, onComplete:completeHandler});
    loader.load();
}

function imageProgressHandler(event:LoaderEvent):void {
    mc_progress.progressBar_mc.bar_mc.scaleX = event.target.progress;
}

function completeHandler(event:LoaderEvent):void {
    aSlider.addEventListener(SliderEvent.CHANGE, scrubber);
    stage.addEventListener(Event.ENTER_FRAME, trackFrame);
    mainSWF = LoaderMax.getContent("main");
    addChildAt(mainSWF, 0);
    container = mainSWF.rawContent;
}

Are you using a 3rd party tool like you mentioned in a different post? Something from JumpEye Components? I just wonder if that's doing something that's preventing proper gc (just a guess). 

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