Go Back   kirupaForum > Flash > ActionScript 3.0

Reply
 
Thread Tools Display Modes
Old 11-23-2009, 05:59 PM   #1
jesseclark
Jesse Clark
Location Northern Colorado

Posts 10
UIloader not completely unloading (music)

I have an application that calls external SWF files through the UILoader component. I do this so I can keep the file size smaller in the beginning and only load objects as the user needs. (if there is a better way to do this, please let me know).

Here is my problem. One of the objects plays music. In it's simplest form something like this:

var sound:Sound;
sound = new Sound( );
sound.load(new URLRequest("fightsong.mp3"));
sound.play();

From the first application, I load the second application and the music starts playing. However, when I unload the second application the music continues to play. The applications can not talk to each other (I assume) because it is basically one SWF calling another SWF via the UILoader.

In my first application, when the uiloader is closed I have:
theLoader.unload();

however the music continues to play. Any suggestions? Can the two SWFs communicate with each other? Is there an eventlistener for exiting? or is there a better way to handle this all together?

Thank You!
jesseclark is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 11-23-2009, 06:39 PM   #2
a tadster
tadster
 
a tadster's Avatar
can't you stop the sound before you unload the loader?

And is this happening for you in FireFox or just IE or the swf itself, alone?

__________________
www.actiontad.com
a tadster is offline   Reply With Quote
Old 11-23-2009, 06:45 PM   #3
jesseclark
Jesse Clark
Location Northern Colorado

Posts 10
yes there is a stop button on the second application that will stop the music. But if they don't hit that, and the application gets closed before, then the music still plays. I need a way to automatically stop the music when it gets unloaded.

thx.
jesseclark is offline   Reply With Quote
Old 11-23-2009, 07:18 PM   #4
a tadster
tadster
 
a tadster's Avatar
right, right, there are two swfs, i overlooked that, yes they can communicate -
you can use the LocalConnection object or even the external interface and add callBacks from one to another:

i'm used to doing it via the external interface:

in the one with sound, set up a function that can get called to stop the sound:

ActionScript Code:
function stopSound():void
{
//do sound stop
//this functions code can be similar to the code you have on the stop button
}

//then set up a external interface callback that when called will invoke the above function

if (ExternalInterface.available) {ExternalInterface.addCallback("stopTheSound", stopSound);}

//now, this part is a bit fiddly , but you need to call a javaScript function that will call stopTheSound
//on the swf , so in your wrapper you'll have a function like this:
 


Code:
<script type="text/javascript">
function callForTheSoundStop()
{
//it may take more than this to reference your swf, this is a general example
document.getElementById("theIdofYourSWF").stopTheSound();
}
</script>
ActionScript Code:
//now, right before the second swf is to be unloaded, call:

ExternalInterface.call("callForTheSoundStop");

//and that should work, however i'm not sure how the fact that it's a swf inside a swf will effect things
//but that's a general solution and how i do things
//the normal way is via the LocalConnection
 

__________________
www.actiontad.com
a tadster is offline   Reply With Quote
Old 11-24-2009, 01:56 PM   #5
jesseclark
Jesse Clark
Location Northern Colorado

Posts 10
Thank you so much for your reply!

It seems kinda like a hack, having one swf file talk to the other via javascript but it works! This just saved me a TON of time. again, thank you very much!
jesseclark is offline   Reply With Quote
Old 11-24-2009, 02:38 PM   #6
a tadster
tadster
 
a tadster's Avatar
cool, glad it worked for you!

__________________
www.actiontad.com
a tadster is offline   Reply With Quote
Reply

Tags
as3, components, music, sound, uiloader


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:05 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com