Switch to Book Layout1: Getting Started2: Building Logic
3: Actors
4: Scenes
5: Game Mechanics6: Advanced Topics7: Testing & Tuning8: The Last 10%M1: Mobile - IntroM2: Mobile - BasicsM3: Mobile - ServicesM4: Mobile - PublishingA: Troubleshooting
B: How-To Guides
C: ReferenceD: Resources3.0 Drafts (In Progress)
|
|||||||||||||||||||
|
Level: Beginner
Code ModeStencyl supports Code Mode, a way to write behaviors entirely using code (currently, ActionScript 3). This article surveys the interface and explains how to accomplish crucial tasks, such as defining attributes through annotations.
Contents
The Interface
Top Tool Bar
This area has four separate buttons, Check Syntax, Refresh Attributes, Open in External Editor, and View API.
Attributes PaneThe Attributes Pane stores all attributes currently defined by this behavior. To define attributes, you have to annotate them. Scroll down to the "How to Define Attributes" section for further details.
Editing AreaThis area is split in to two sections, one where you add new code, and the other area that shows compiler output when you press Check Syntax. Syntax highlighting and simple code completion are supported, as well as find/replace.
Using External EditorsStencyl plays nice with external editors such as Notepad and FlashDevelop. Configure this setting inside Preferences > Workspace. It will open up the editor on demand and auto-sync the changes when you save in that external editor.
Note: In the future, we will begin bundling FlashDevelop, which is in the process of being ported to Mac and Linux and will support more languages than just ActionScript.
Switching Between Design and Code ModeAt this point in time, we don't support switching between these two modes. It's possible in the future for there to be a one-way conversion from Design Mode to Code Mode, but the reverse will likely be impossible to do (think about it...)
How to Define AttributesIn order to expose a class member for a Code Mode Behavior as a configurable attribute, you need to annotate it. The easiest way to learn the syntax is by example. //Expose your attributes to Stencyl like this [Attribute(id="1", name="Display Name", desc="An Attribute")] public var attributeName:String = "default";
Accepted Properties
The Types
The FutureBy Stencyl 3.0 and possibly sooner, we will completely replace and revamp the code editing experience with something significantly more advanced and productive for serious coding. Stay tuned!
Last Updated: 2012-05-13 by Ceric
11977 have read this article
Disclaimer: The Stencyl Team does not actively monitor comments on articles. If you're seeking help for your game,
please ask a question on the forums. Thanks!
5 Comments
gammaworld1
Suggestion for Code/Design mode: Make the Code Mode with blocks of code available for the user the input, but the relevant parts show up in Code Mode greyed out. That way the user can decide if he wants to optimize or not. If not, the user can always select to not permanently alter the code. If would be VERY fun to learn this way :) 0 4 weeks ago
SyKot
"int" or integers, as the name states are integer numbers. In other words, numbers like, ...-2,-1,0,1,2.... With ints you cannot store fractions such as 3.14. "uint" are unsigned int. They only store positive numbers. -2 11 months, 1 day ago |














