The Add External Code window allows you to add Lua code into your project. It requires Flash configuration to keep your code. When pressed, the following window appears:
- Name: enter a name to your block of code (this is needed in the case you need to edit the code later). Kwik auto create an name but it is always a good idea to enter your own names for easy access later;
- Enter or paste your code: the code you want to add into your project (Kwik does not validate the code for you so, test it before and after your publish your page);
- (new in 2.3) From file (use the Browse button to point to the external code file): gets the file containing the external code (it will be copied into the page file during the Publish process).
- Top, Middle or Bottom of the page: defines where the block of code will be entered in your page. Check a previously published page to see where the blocks will be entered (look for lines containing “– External code will render here”). Top blocks will be added before the page layers rendering. Middle blocks will be rendered just after the groups creation. Bottom blocks will be rendered after the background swipe code, at the end of your page file.
- Disposal area: since version 2.2 it is possible to create code in the Disposal area (used to cleanup animations, events, etc). This allows, for example, the removal of event listeners created using external code.
Starting in 2.3, Kwik will check for characters that may crash your project file (only in the Flash editor, as external file content will not be added into your .kwk project file). In the case of a problematic, but not known by Kwik yet, character crashes your project, Kwik will save a backup file with the content before the external code being added, which can be used to restore your original project. In order to do so:
- Check/open file <projectName>_<date>_<time>.kwk (same folder of your project);
- Copy its content;
- Open file <projectName>.kwk (it will be empty), paste the contents into this file and save it;
- Open your project again.