|
-
Unload swf from memory after <div> is hidden
Hi all - I tried a search but it keeps saying I failed the No Spam when I didnt get a question - d'oh.
Ok, this has probably been covered before, but a lot of research hasn't got me far, so I thought I'd post. I have a single page html site with several links that load up a homebrewed lightbox. The inline content is written out at the bottom of the page and the divs are set to hidden.
When a link is clicked, the light box loads and the correct <div> is set to visible. The flash plays, or is interacted with but when the user has finished, they click an html Close button and the div is hidden again. Obviously the swf is still loaded and running; it could be even mid animation. The more swfs loaded, the more memory that is taken up.
My development machine can handle the 600mb + used up by have a few FF windows open and a couple of copies of the site; but I imagine it will cause problems for users. So I've been looking into externalInterface to fire a command into the swf to close itself down when the close button is clicked, but I can't seem to find anything - any pointers or suggestions?
many thanks
frank
-
i havent used the external interface before, but after reading the livedocs im guessing that this is how you do it. you wanted to remove flash players from the html when a button in flash is clicked right?
include this in the flash object on html:
Code:
<param name="allowScriptAccess" value="always" />
in html include this javascript:
Code:
function removeFlash() {
document.getElementById('flash_container').removeChild('flash_object');
}
you can make it dynamic by including a parameter for multiple flash objects:
Code:
function removeFlash(flashContainer, flashObject) {
document.getElementById(flashContainer).removeChild(flashObject);
}
now in AS3 the button event should call a function like this:
Code:
function callJSRemove(e:MouseEvent):void {
ExternalInterface.call(removeFlash, .... params);
}
this however is only 'part' of the code necessary to do it. but using this external interface call function you can do it, i suggest you follow this link and try out the example it has:
http://livedocs.adobe.com/flash/9.0/...tml#call%28%29
EDIT:
byhook has come up with some interesting stuff only today :P
http://board.flashkit.com/board/showthread.php?t=806693
this example of his uses the enternal inferface:
http://labs.byhook.com/?p=236
Last edited by flosculus; 12-08-2009 at 08:25 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|