Event Dispatching From External SWF

Hello!

I’m working on a project and had a question related to another thread I recently posted earlier this week regarding an area I was a little stuck on… http://www.kirupa.com/forum/showthread.php?t=349924 I’m newly transitioning from AS2 --> AS3, so hoping someone can possibly help me here! :slight_smile:

While I did manage to resolve most of my issue, there’s still a piece of the puzzle that’s missing. I basically have one main container swf that loads several external swfs into a MC and cycles through an array of external files. I have navigation buttons so the user can click next to proceed through all of the external content files. My goal here, is to not have the “next button” become active until after the external files are done playing, so they can’t skip ahead.

I currently have this working by having the external swf dispatch an event (from its final keyframe) to the main swf telling the main swf it’s done playing, and then activates the next button on completion. This works great; however, I can’t seem to get it to dispatch this event on any of the sequential swfs – it only does this for the first swf initially loaded. Is there a way to “reset” the event to detect the end of the other swfs and continue in this fashion? Or another possible solution so I can apply this to each external swf?

Here is the code I have in the main container swf:


//Array of external swfs
var contentArray:Array = new Array("content1.swf", "content2.swf", "content3.swf"); 
var currentIndex:int = 0; 

//Listener for Loader, check when complete
content_container.addEventListener(Event.COMPLETE, handleLoadComplete);

//Load first swf
var contentRequest:URLRequest = new URLRequest(contentArray[currentIndex]);
content_container.load(contentRequest);

//event handler triggered when external swf is loaded
function handleLoadComplete(event:Event) {
    (event.currentTarget.content as  
   MovieClip).addEventListener("COMPLETE", contentComplete);
    trace("Just loaded "+contentArray[currentIndex]); 
}

function contentComplete(event:Event):void {
     //make next button available now... 
     trace("Content now complete.");
     next_btn.addEventListener(MouseEvent.CLICK, nextBtn); 
}

function nextBtn(evt:MouseEvent=null):void {
    trace("Next button clicked");
    //Load new content
    if (currentIndex < contentArray.length - 1) {
        currentIndex++; 
        var contentRequest:URLRequest = new   
       URLRequest(contentArray[currentIndex]);
        content_container.load(contentRequest);
        } else {
        trace("End of content");
    }
}

And in the final frame of each external swf to let the main swf know when it’s done playing:

dispatchEvent(new Event("COMPLETE"));

Anyway, so close but can’t quite get it right! Any help would be greatly appreciated!! :smiley: Thanks much!