[Flashjs] javascript delete keyword...

Kevin Newman CaptainN at adcstudio.com
Wed Jul 13 21:20:42 PDT 2005


I was looking through the code (trying to debug something unrelated..) 
and found the removeFlashVar function. It looks like you are setting the 
array property to undefined. Is there a reason that you do it this way 
instead of using the javascript delete keyword?

This is what I came up with:

FlashTag.prototype.removeFlashVar = function(n)
{
     delete this.flashVars[n];
};

Then in the getFlashVarsAsString method, you could change the iteration to:

for (var n in this.flashVars)
{
     // no need to check if the value is undefined?
     qs += (escape(n)+'='+escape(this.flashVars[n])+'&');
}


unless of course I'm missing something.

Here is the test that I used to see if this should work:

var test = new Array('element 1', 'element 2', 'element 3');
delete test[1];
for (var n in test) {
     alert(test[n]);
}

This test also revealed that the IE 5 patch that I submitted, messes up 
the iteration of all objects - so I'll have to come up with some other 
way to deal with IE 5.


There are other places in the code where this might apply, if it is an 
acceptable method for dealing with the removal of array (or object) 
properties.

What do you think?

Kevin N.

P.S. I attached a .patch file, just in case it's useful.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: FlashTag.js.zip
Type: application/x-zip-compressed
Size: 2012 bytes
Desc: not available
Url : /pipermail/flashjs_osflash.org/attachments/20050714/000252bd/FlashTag.js.bin


More information about the Flashjs mailing list