-
-
Notifications
You must be signed in to change notification settings - Fork 41
Code Generation
The NextGen ActionScript extension for Visual Studio Code includes several code actions (also known as quick fixes) for code generation. If a code action is available at the current position in the editor, a lightbulb icon will appear in the left margin of the current line. Click this icon to open a menu to choose from the available code actions. Alternatively, you may use the Ctrl+. keyboard shortcut to open the menu.
If you try to reference a variable that doesn't exist, the compiler may produce an error like this:
Access of possibly undefined property {propertyName}.
When this compiler error is detected, the Generate Local Variable code action will allow you to generate a variable inside the current function, like this:
var someValue:Object;
Similarly, the Generate Field Variable code action will allow you to generate a field (or member) variable like the one below:
public var someValue:Object;
If you try to call a method that doesn't exist, the compiler may produce an error like this:
Call to a possibly undefined method {methodName}.
When this compiler error is detected, the Generate Method code action will allow you to generate a method from a call like the one below:
refresh(10, true);
The generated method will include any parameters that you attempted to pass to it, with the correct types (which will be imported, if necessary):
private function refresh(param1:Number, param2:Boolean):void
{
}
If your class contains a member variable, like the one below, you may use the Generate Getter and Setter code action to convert it into a getter and setter.
public var enabled:Boolean = true;
The generated functions will have the same access level (like public
or private
) and type as the old variable and the new private variable will be initialized to the same value:
private var _enabled:Boolean = true;
public function get enabled():Boolean
{
return _enabled;
}
public function set enabled(value:Boolean):void
{
_enabled = value;
}
- Adobe AIR (Mobile)
- Adobe AIR (Desktop)
- Adobe Flash Player
- Apache Royale
- HTML and JS (no framework)
- Node.js
- Feathers SDK
- Adobe Animate
- Classic Flex SDK
- Library (SWC)
- Royale Library (SWC)