I’m on my 3rd generation swf loader, which is a loader container, with a menu that can load many external swf files, and then unload them and go back to the menu.
I made a MovieClip Container that holds the menu items for the external swf files. An empty MovieClip Container is made, waiting for a menu item click that will load the external swf into it using addChild(_movie_Container);
When done, you can click the return key, which calls removeChild(_movie_Container).
The external swf contain an audio track, which is called from code. The audio is stored in the library, and called into action when the sync point is correct.
Everthing works fine except for the audio. When you press the return button, the external swf is killed, but the audio keeps playing.
I know how to stop the audio using code. But I would like to stop the audio in the master container. If I start the audio in the master container, I will lose sync, but I will be able to stop the audio.
There must be a way to communicate with the external swf that is loaded, and kill the audio. Here is the sample. http://www.harbourlandingdental.com
import caurina.transitions.*;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.display.SimpleButton;
import flash.events.*;
import flash.text.TextField;
import flash.net.*;
//** Menu Buttons **//
bt_SpecialOffer.addEventListener(MouseEvent.MOUSE_UP, load_SpecialOffer);
bt_GetDirections.addEventListener(MouseEvent.MOUSE_UP, load_GetDirections);
bt_ServicesOffered.addEventListener(MouseEvent.MOUSE_UP, load_ServicesOffered);
bt_DentalTreatments.addEventListener(MouseEvent.MOUSE_UP, load_DentalTreatments);
var Return_Button:SimpleButton = new bt_Return();
//** External SWF Movie Container **//
var _container_Movie:MovieClip = new MovieClip();
_container_Movie.width = 600;
_container_Movie.height = 338;
_container_Movie.x = 0;
_container_Movie.y = 32;
//** Universal Progress Indicator **//
var myProgressWheel:MovieClip = new mc_ProgressWheel();
myProgressWheel.x = 300;
myProgressWheel.y = 161;
//** Universal Loader **//
var loader:Loader = new Loader()
//** Load Functions **//
function load_SpecialOffer(event:MouseEvent): void {
Return_Button.x = -350
Return_Button.y = 175
this.addChild(Return_Button)
Tweener.addTween(Return_Button, {x:-295, y:175, time:1, transition:"linear"});
Return_Button.addEventListener(MouseEvent.MOUSE_UP, return_GetDirections);
stage.addChild(_container_Movie);
_container_Movie.x = -600;
_container_Movie.y = 32;
Tweener.addTween(_container_Movie, {x:0, y:32, time:1, transition:"linear"});
var request:URLRequest = new URLRequest("/Flash/HLD_SpecialOffer_02.swf");
loader.load(request);
_container_Movie.addChild(myProgressWheel);
_container_Movie.addChild(loader);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.contentLoaderInfo.addEventListener(Event.OPEN, openHandler);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
loader.load(request);
}
function load_GetDirections(event:MouseEvent): void {
Return_Button.x = -350
Return_Button.y = 175
this.addChild(Return_Button)
Tweener.addTween(Return_Button, {x:-295, y:175, time:1, transition:"linear"});
Return_Button.addEventListener(MouseEvent.MOUSE_UP, return_GetDirections);
stage.addChild(_container_Movie);
_container_Movie.x = -600;
_container_Movie.y = 32;
Tweener.addTween(_container_Movie, {x:0, y:32, time:1, transition:"linear"});
var request:URLRequest = new URLRequest("/Flash/HLD_GetDirections_02.swf");
loader.load(request);
_container_Movie.addChild(myProgressWheel);
_container_Movie.addChild(loader);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.contentLoaderInfo.addEventListener(Event.OPEN, openHandler);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
loader.load(request);
}
function load_ServicesOffered(event:MouseEvent): void {
Return_Button.x = -350
Return_Button.y = 175
this.addChild(Return_Button)
Tweener.addTween(Return_Button, {x:-295, y:175, time:1, transition:"linear"});
Return_Button.addEventListener(MouseEvent.MOUSE_UP, return_GetDirections);
stage.addChild(_container_Movie);
_container_Movie.x = -600;
_container_Movie.y = 32;
Tweener.addTween(_container_Movie, {x:0, y:32, time:1, transition:"linear"});
var request:URLRequest = new URLRequest("/Flash/HLD_ServicesOffered_02.swf");
loader.load(request);
_container_Movie.addChild(myProgressWheel);
_container_Movie.addChild(loader);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.contentLoaderInfo.addEventListener(Event.OPEN, openHandler);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
loader.load(request);
}
function load_DentalTreatments(event:MouseEvent): void {
Return_Button.x = -350
Return_Button.y = 175
this.addChild(Return_Button)
Tweener.addTween(Return_Button, {x:-295, y:175, time:1, transition:"linear"});
Return_Button.addEventListener(MouseEvent.MOUSE_UP, return_GetDirections);
stage.addChild(_container_Movie);
_container_Movie.x = -600;
_container_Movie.y = 32;
Tweener.addTween(_container_Movie, {x:0, y:32, time:1, transition:"linear"});
var request:URLRequest = new URLRequest("/Flash/HLD_DentalTreatments_02.swf");
loader.load(request);
_container_Movie.addChild(myProgressWheel);
_container_Movie.addChild(loader);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.contentLoaderInfo.addEventListener(Event.OPEN, openHandler);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
loader.load(request);
}
//** Unload Movie Container Functions **//
function return_SpecialOffer(event:MouseEvent): void {
loader.unload();
trace("====>return_SpecialOffer");
Return_Button.removeEventListener(MouseEvent.MOUSE_UP, return_GetDirections);
this.removeChild(Return_Button);
stage.removeChild(_container_Movie);
}
function return_GetDirections(event:MouseEvent): void {
loader.unload();
trace("====>return_GetDirections");
Return_Button.removeEventListener(MouseEvent.MOUSE_UP, return_GetDirections);
this.removeChild(Return_Button);
stage.removeChild(_container_Movie);
}
function return_ServicesOffered(event:MouseEvent): void {
loader.unload();
trace("====>return_ServicesOffered");
Return_Button.removeEventListener(MouseEvent.MOUSE_UP, return_GetDirections);
this.removeChild(Return_Button);
stage.removeChild(_container_Movie);
}
function return_DentalTreatments(event:MouseEvent): void {
loader.unload()
trace("====>return_DentalTreatments");
Return_Button.removeEventListener(MouseEvent.MOUSE_UP, return_DentalTreatments);
this.removeChild(Return_Button);
stage.removeChild(_container_Movie);
}
function loadProgress(e:ProgressEvent):void {
var bytesDownloaded:Number = e.bytesLoaded;
var totalBytes:Number = e.bytesTotal;
var perc:Number = e.bytesLoaded / e.bytesTotal;
myProgressWheel.txt_percent.text = Math.ceil(perc*100).toString() + "%";
}
function loadComplete(e:Event):void {
loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, loadProgress);
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadComplete);
loader.contentLoaderInfo.removeEventListener(Event.OPEN, openHandler);
loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, progressHandler);
loader.contentLoaderInfo.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
}
function progressHandler(event:ProgressEvent):void {
trace("====> progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
}
function securityErrorHandler(event:SecurityErrorEvent):void {
trace("====> securityErrorHandler: " + event);
}
function httpStatusHandler(event:HTTPStatusEvent):void {
trace("====> httpStatusHandler: " + event);
}
function openHandler(event:Event):void {
trace("====> openHandler: " + event);
}
function inIOError(event:IOErrorEvent):void {
trace("====> IOErrorHandler: " + event);
}