all groups > flash actionscript > february 2004 >
You're in the

flash actionscript

group:

adding Array.prototype.sortEquals BUG


adding Array.prototype.sortEquals BUG fsharpmajor
2/12/2004 9:31:25 PM
flash actionscript:
I have come across a bizarre bug. I put the code into a frame (originally in
an .as file), and then I put a component button (MX 2004 Pro) onto the stage.
I then run the program. I press a bunch of keys and nothing happens (no new
traces), which is completely to be expected. BUT!!! If I press the component
button, then all of a sudden I am getting the traces from this function if I
press any buttons. Am I overwriting an undocumented array function? I thought
checking if it was undefined would solve that. Any ideas



if (Array.prototype.sortEquals == undefined)
Array.prototype.sortEquals = function(passedArray:Array,
passedSortFunction:Function, passedORedOptions, bSameLength:Boolean)
var tempThisWorkingArray:Array = new Array()
var tempPassedArray:Array = new Array()
tempThisWorkingArray.copy(this)
tempPassedArray.copy(passedArray)
if (passedSortFunction)
tempThisWorkingArray.sort(passedSortFunction, passedORedOptions)
tempPassedArray.sort(passedSortFunction, passedORedOptions)
} else
tempThisWorkingArray.sort(passedORedOptions)
tempPassedArray.sort(passedORedOptions)

trace("~~~")
trace("from the fruit")
trace("tempThisWorkingArray = "+tempThisWorkingArray)
trace("tempPassedArray = "+tempPassedArray)
trace("~~~")
var isEqual:Boolean = tempThisWorkingArray.equals(tempPassedArray,
bSameLength)
return isEqual
}
trace("Array.prototype.sortEquals created")
} else
trace("Array.prototype.sortEquals already exhists")



--bb
Re: adding Array.prototype.sortEquals BUG fsharpmajor
2/13/2004 8:20:26 PM
It seams that if I attach more than one function to the prototype all of them
get called in this scenero. And they are called multiple times onKeyPress for
some reason. I can't find any code in Macromedias components that would lead
to this behavior either. Any ideas

--bb
AddThis Social Bookmark Button