Compiling ActionScript 3.0 with sublime text 2

Source: Internet
Author: User
Tags stack trace

At clock we typically spend our time developing JavaScript and PHP, however, occasionally flash presents itself as the most suitable platform for certain components. to avoid the need of installing a separate Authoring Environment (and even the license fees associated with some of the official Adobe IDE's) I sought to empower my text editor sublime text 2 with the ability to compile SWF's.

Choosing to use a minimalist development environment is invariably going to bring about some limitations, of these I find the most noticeable to be the lack of debugging tools. while I will suggest some means to allow you to receive trace statements to debug your application, if you're developing large and complex applications you may be want to consider some other free alternatives: Flash develop.

Download Flash compiler and. SWF viewing Software

If you don't have any kind of Flash authoring environment installed, you're going to need to download some software:

  • A version of the Flex SDK is needed to compile your application (Version: If you're not sure,AdobeFlex SDK is likely to be appropriate)
  • You'll probably want an SWF debug projector to enable you to run your SWF's on the desktop and provide stack trace output.
  • Additionally one of the plugin content debuggers will be useful for access stack traces in the browser.

You'll notice that the first two of these applications don't come with any kind of installer, it's up to you where you want them, (as a Windows 7 user) I extracted them bothC:\Program Files (x86)\Flex SDK\

Refreshing ing mxmlc as a build system in sublime text 2

Now you 've got your flex SDK extracted you'll want to set it as what's known in sublime text asBuild System.

In sublime's menu, access:Tools > Build System > New Build System…

Replace the default build script with the following:

{  "cmd": [    "C:\\Program Files (x86)\\Flex SDK\\bin\\mxmlc.exe",    //"-o", "${project_base_name}.swf",    "${file}"  ],  "selector": "source.actionscript"}

Save this file in sublime's ActionScript package Directory, which for Windows 7 users will be located inC:\Users\[username in here]\AppData\Roaming\Sublime Text 2\Packages\ActionScript\, And restart sublime. You shoshould now be able to build your flash projects usingF7OrCtrl + bAnd using the aforementioned SWF projector you'll be able to launch your fresh SWF from your file system.

Sublime's build system notes

TheselectorOption will make sublime choose our new build system automatically when you build directly from the source view of an ActionScript file. in the example above you'll see that my Windows File System requires me to escape the directory separator. you'll have to modify this path if you're on a different operating system or you selected a different place for your flex SDK to live. one thing which caught me out was providing additional command line parameters to sublime, they must be provided as per the-O option above. individual option flags and Their attribute must be placed into separate elements inCMDArray for sublime to execute them correctly. I 've left in the above example as a reference to this.

Hello World

As requested, here is a littleHello WorldTo test your compiling powers:

package {  import flash.display.Sprite;  import flash.text.TextField;  // import flash.external.ExternalInterface;public class HelloWorld extends Sprite {public function HelloWorld () {// ExternalInterface.call("console.log(‘ding‘)");      var mytextfield:TextField = new TextField();      mytextfield.text = "Hello World!";      addChild(mytextfield);    }  }}
Debugging your flash applications in a javascript Console

Now we 've cut the flash ide out of the equation, you 've actually lost your flash console meaning yourtrace()Statements aren't going to get shown anywhere, evenFlash Player debuggersCan only output stack traces. the most suitable way I found to output debugging information was by embedding my. SWF in a webpage and outputting data to the browsers console. by utilising Flash's externalinterface class you're able to invoke JavaScript Functions, more specifically in Firefox the firebug console, or Chrome's native JavaScript console.

After importing the class into your application you can simply call the console like so:ExternalInterface.call("console.log(‘ding‘)");

This does, however, rely on the fact that you're re running your SWF in a browser and importantly that your console is loaded before you call it (embedding usingswfobject will help avoid errors relating to this ).

If you're debugging needs go very far beyond this, then its probably time to install a more integrated development environment with native debugging and profiling support.

Refrences and recommended IDE's
  • Http://sublimetext.info/docs/en/reference/build_systems.html-sublimes build properties
  • Http://www.arulraj.net/2010/08/flash-player-debugger-in-ubuntu.html-installing the plugin content debugger on Ubuntu
  • Http://www.flashdevelop.org/wikidocs/index.php? Title = main_page-flash develop ide
  • Http://fdt.powerflasher.com/-FDT, eclipse based ide

Compiling ActionScript 3.0 with sublime text 2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.