fabriciocs / swfobject

Automatically exported from code.google.com/p/swfobject
0 stars 0 forks source link

What is the recommended way of destroying an object #71

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. A swf with a rather beefy new BitmapData(800,600,...)
2. Use IE7, Create a swfobject in a containing div, then destroy it by
setting innerHTML of swf's owner to ''.
3. Goto 2

What is the expected output? What do you see instead?
I expect it to work. Instead i rather quickly get:
ArgumentError: Error #2015: Invalid BitmapData.
    at flash.display::BitmapData()
    at
FlvplayerEmbedded()[C:\slask3\flash\AS3\projects\pond5FlashPlayer\FlvplayerEmbed
ded.as:106]
    at Main/Main2()[C:\slask3\flash\AS3\projects\pond5FlashPlayer\Main.as:73]

What version of the product are you using? On what operating system?
Flash 9.0 r115 debug version, IE7 + latest patches
Prototype 1.6.0.2

Please provide any additional information below.
This it not really a bug report. It's more of a question to include a
destroySwf() to your lib or add a recommendation of a good way of killing
off dynamically created swf:s.

I'm happy to make a test page if you want.

Original issue reported on code.google.com by ehsm...@gmail.com on 15 Apr 2008 at 10:53

GoogleCodeExporter commented 9 years ago
> This it not really a bug report.

Next time please post this question at the SWFObject discussion group:
http://groups.google.com/group/swfobject

In any case the following should work:

function destroySWF() {
    var obj = document.getElementById(yourId);
    if (obj) {
        for (var i in obj) {
            if (typeof obj[i] == "function") {
                obj[i] = function() {};
            }
        }
        obj.parentNode.removeChild(obj);
    }
}
swfobject.addLoadEvent(destroySWF);

Please let me know if this work for you, otherwise please up a test page.

Adding something like this to the library, I am not really sure for how many 
people
this will be useful, so its under consideration.

Original comment by bobbyvandersluis on 16 Apr 2008 at 9:18

GoogleCodeExporter commented 9 years ago
Here is a test page:
http://engene.se/swfobjectcleanup.html

I've added an argument...
"apa=" + Math.round(daten.getTime() / 10000)
...to the swf name which makes it come alive quite quickly. If apa is unique 
every
time (e.g removing / 10000), it works fine, but it feels like swooping dust and 
dead
animals under the rug.

I've made the swf myself so the source for it is available, should there be any 
need
for it.

Sorry for not posting this in the forums. Should I post this there instead now?

Thanks!
Marcus

Original comment by ehsm...@gmail.com on 16 Apr 2008 at 11:08

GoogleCodeExporter commented 9 years ago
If it's still an issue or if you would like to discuss it, please post it at the
discussion group.

Furthermore, please make sure that your Flash has been fully loaded by IE before
killing it, because you cannot cancel a loading asset in IE without breaking 
references.

Original comment by bobbyvandersluis on 17 Apr 2008 at 8:53