In the comments of my last post, James Thompson kindly pointed out that fl.actionsPanel has getText() and setText() methods, not to mention setSelection(). Thanks James! With this, I was able to get cursor positioning in there. Just put “&cursor” anywhere in the snippet, and with any luck, that’s where the cursor will go after the text replacement is done.
Got pretty messy doing that. The string in JSFL and the string in the editor return different values for getIndexOf() – seems to vary on newline characters. So I had to assign the text with the cursor info, get the index, replace the cursor info with nothing, and reassign the text. Also it wouldn’t find the &cursor string if it was followed by a newline either, so I’m just searching for &curso, which is pretty hacky but works.
Also slapped an MIT license in there and made it available for download.
https://www.bit-101.com/extensions/ASExpander.jsfl
Again, put it in your commands folder in Flash CS3 / CS4:
Mac: /[user]/Library/Application Support/Adobe/Flash CS3/en/Configuration/Commands
Windows: \Documents and Settings\username\Local Settings\Application Data\Adobe\Flash CS3\language\Configuration\
And assign a shortcut key to that command.
Also, check it out, we have video of it already!
https://www.video-flash.de/index/asexpander-code-snippets-in-flash/