Let me translate for Gust:
"Typing" means declaring what a variable is.
Typed:
var Blah:Number
Non - Typed
var Blah
When you don't Type a variable, it has to look up what it is, which is called hashing, and this takes time to do. When you're looping a line of code 1000 times, that lookup time is expounded and slows your stuff way down.
Function Local variables are once you simply declare within you function:
function Blah(){
var Blah:Number
}
These work faster within the function and will free up memory later when the function is done and the variable is deleted.
For the locking and unlocking, do the lock BEFORE your whole loop, then unlock AFTER it. Not sure what you tried, but that's the proper way to do it.
You might find this thread useful, as I basically went over these same things with Gust and Dougy. Thanks again dudes! :3