Add External Code

Toolset: Project and Pages

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:

Screen Shot 2013-03-06 at 4.27.49 PM

  • 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.

11 Comments

  1. I can edit the .lua files and add
    print (“HELLO WORLD”)
    and this works fine.
    But when I attempt to use the Add Code box and type in the same thing it is not
    displaying to the console, instead it displays an error:
    Corona Simulator: Director ERROR: Failed to execute new( params ) function on ‘page_1′

  2. Is it possible to fire off a script after every publish? With some version control magic you might could make a post hook that reimports patches from all your code every time you publish in an automated way to make a deeper level of customization possible.

    • Kwiksher

      Bu, which one exactly are you interested? It is important to understand that you will never be able to simply “add another Lua coide” into your project. Each project has particularities like object names, different functions, etc.

      The ability to add external code was created for people and teams with Lua knowledge. If you are not familiar with code, I am afraid to say, you will not be able to do much things here.

  3. JCP

    Hi,

    I think I have a bug, I just installed version 2.2.4 and when i added code using the “add external code” function click the create button and try to re-open it again there is no code. I deployed the project and looked at the lua code I could not find the code at all, am i missing a step or is this a bug?

    Thank you,
    JCP

Leave a Reply