ASExpander 1.1
Sunday 2 November 2008 - Filed under Extensibility + Flash
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.
http://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!
http://www.video-flash.de/index/asexpander-code-snippets-in-flash/
2008-11-02 » keith
2 November 2008 @ 9:30 pm
[...] I just released version 1.1 of ASExpander. http://www.bit-101.com/blog/?p=1627 . This post is still worth reading for background and usage, but check out the other one for the [...]
2 November 2008 @ 10:16 pm
[...] Keith has already posted an update to the script and made it available via download under the free MIT license, and I highly recommend checking it out. [...]
2 November 2008 @ 10:36 pm
oops, little typo in the enterframe handler. fixed. v 1.1.1 is the one up there now.
3 November 2008 @ 3:51 am
I had some problems with cursor position on Mac. So I figured out this:
invisibles = script.split(“\n”).length + script.split(“\r”).length;
fl.actionsPanel.setText(script);
index = fl.actionsPanel.getText().indexOf(“&curso”) + invisibles;
Seems to work?!
3 November 2008 @ 4:15 am
Blah, it doesn’t work if you are adding snippets in the middle of the script. So you can remove previous comment, sorry. But there are some problems with new line & return characters..
3 November 2008 @ 4:59 am
Hello,
I’ve question about the documentation of JSFL, where do you find it ?
I never find anything really complete, juste only some demostration or a begin of explanation.
And without documentation, it’s difficult to know what is the limits of this language.
Thank’s a lot.
3 November 2008 @ 6:07 am
Dear Keith,
I want to do a PhD on ActionScript 3.0. I am reading your book on Animation. My idea is “What model does Flash give you leading to ….”I am not sure that is sufficient for a PhD. Have you any ideas?
Regards
Hugh
3 November 2008 @ 7:48 am
[...] BIT-101 Blogã§ASExpander 1.1ã¨ã„ã†Actionsctipt(フレームアクション)スニペットãŒå…¬é–‹ã•れã¦ã„る。 [...]
3 November 2008 @ 8:10 am
Ville, I’m on a Mac too and it’s working fine for me. Although, like I said, it was pretty tough, so I’m not surprised there’s still some glitches in it. Does it not work correctly with the snippets I provided?
Armetiz, I wrote the book Extending Flash MX 2004 with Todd Yard. It’s still the only complete book on the subject. It’s missing some of the newer stuff, but overall holds up pretty well for a 4 year old tech book.
Hugh. I’m not sure what you are asking.
3 November 2008 @ 11:42 am
Thk you so much
That is definitely a very non intrusive solution to make flash ide a better coding machine
4 November 2008 @ 1:33 am
Hi keith, I’m still trying how to use this ASExpander, I can’t get it work, maybe you can give me a guide how to assign a shortcut key, since I’am new at user script (.jsfl)
.
.
thanks ^^
4 November 2008 @ 1:41 am
Ahhh, finally I’ve figured out how to use this ASExpander, once again, thanks for this useful script ^_^
.
.
5 November 2008 @ 2:59 pm
Can anyone provide a quick post/guide on how to create a shortcut key for this command?
Thanks.
6 November 2008 @ 12:55 pm
Pretty good and surprisingly simple!, thanks Keith.
29 November 2008 @ 5:26 pm
Hi iv tried this and get
The following JavaScript error(s) occurred:
At line 56 of file “ASExpander.jsfl”:
TypeError: script has no properties
any help on this, i didnt even know flash had this…
10 December 2008 @ 4:21 pm
I get the exact same error, but on line 57. Any help would be great.
10 December 2008 @ 4:32 pm
Not sure what’s going on there. Seems to be failing on this line:
if(script.indexOf(“&help”) != -1)
Which probably means that this line did not work:
script = fl.actionsPanel.getText();
What version of Flash are you using this on?
10 December 2008 @ 4:58 pm
Hi kp,
I tried this on CS3 and CS4 now, i still get the same error.
25 February 2009 @ 5:49 am
Hi Keith, I saw you yesterday on FITC Amsterdam and I’m very interested in ASExpander. I just wanted to ask you if you plan on making it Flex-capable, like with a Flex Builder/Eclipse plugin?
8 October 2009 @ 8:45 am
[...] 1 ding goed werkt, werken meer beter – Math.random() is je beste vriend wanneer je beelden maakt – ASExpander is een handige tool voor as [...]
17 January 2010 @ 9:08 am
I realized that asexpander works fine in a .fla but not when editing a .as.
Is there a way to use commands in a .as ?
Thx
17 January 2010 @ 10:36 am
I don’t think there is a way to access .as docs through JSFL. At least there wasn’t originally. Haven’t really kept up with the updates.