Let’s say you’ve just pasted in a snippet of code, or loaded a file that is missing imports. When you compile, you get errors and you’re stuck importing each definition by hand. Flex Builder provides a bit of a hidden feature here to help you import your missing types: next to each type that is missing, press control-space at the end of the missing definition. Flex Builder will put the import in automatically.
So, when you have:
var foo:AbstractConsumer;
put your cursor between the r and the ; and hit the hotkey. And yes, this is the same as the command to bring up code hints. And yes, Flex Builder should really provide a mechanism to bring in imports on paste…but between now and then, this should work just fine


It’s no use in multi-language OS,when I press the hot-key (Ctrl+Space?) In Windows Vista in Chinese,it’s will change my IME.:)
It’s really just the same hot-key to trigger content assist/intellisense/code hints/whatever you want to call it… use that and you’ll be fine
you can also change vista’s hotkey to anything else…
Thanks for the post David. That is helpful and very non-obvious. I usually fix missing imports using content assist
by triggering it when I type ‘var a:’ and finding the type in the list, so this will definitely save me a lot of extra typing.
I will say it seems strange to me that it can do this but it doesn’t provide ‘proper’ quick fix hinting to let you know it can fix it for you. Also, in addition to generating imports for a cut/paste, it would be nice to have a ‘fix imports’ menu item which attempts to add missing imports, for the case when you open an existing file that is missing it’s imports.
Is it just me or does this only work in .as files and not in .mxml files? (Same is true for ctrl-shift-O)
So Ctrl-Shift-O doesn’t work, however this import trick should work. The condition is that your MXML document must be syntactically valid. In the upcoming version of Flex Builder, we will be relaxing this requirement.