Initial translation from AS to JS.