COMPILING ACTIONSCRIPT 3.0 WITH SUBLIME TEXT 2

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 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, the Adobe Flex 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 both into C:\Program Files (x86)\Flex SDK\

Configuring 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 as a build 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 in C:\Users\[username in here]\AppData\Roaming\Sublime Text 2\Packages\ActionScript\, and restart Sublime. You should now be able to build your flash projects using F7 or Ctrl + b and using the aforementioned SWF projector you‘ll be able to launch your fresh SWF from your file system.

Sublime‘s Build System Notes

The selector option 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 in the cmd array 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 little Hello World to 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 your trace() statements aren‘t going to get shown anywhere, even the flash player debuggers can 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 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

时间: 2024-08-04 04:54:44

COMPILING ACTIONSCRIPT 3.0 WITH SUBLIME TEXT 2的相关文章

kali linux 2.0安装sublime text 2

参考原文: http://www.codeproject.com/Articles/582849/InstallingplusSublimeplusTextplus-plusonplusLinuxp 第一种方法: Download the Sublime Text 2 & Extract it: 32位: $ wget http://c758482.r82.cf2.rackcdn.com/Sublime%20Text%202.0.1.tar.bz2 tar vxjf "Sublime T

Ubuntu安装Sublime Text 2.0.2 32-bit linux

参考资料:http://www.technoreply.com/how-to-install-sublime-text-2-on-ubuntu-12-04-unity/ 1.去Sublime Text官网下载32-bit linux的压缩包 // 64-bit的我反正用不了不知到为什么(报错:bash: /usr/bin/sublime: cannot execute binary file),我的系统是VBOX中的64-bit Ubuntu 2.解压(Extract here),注意解压出来后

sublime text 3设置

Sublime text 3 中文文件名显示方框怎么解决? 如图,中文文件名打开全是乱码,内容倒是装了converttoutf8没什么太大的问题. 作者:凝空虚步链接:https://www.zhihu.com/question/24029280/answer/149772790来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 我来总结下吧,首先这个问题是Sublime Text 3的显示bug,在高分屏下设定显示放大就会触发.解决步骤如下: 1.强制放大倍数为1

右键菜单添加文本编辑器 Notepad2 Sublime Text 2

右键添加Sublime Text 打开方式 Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell\Sublime Text] "Icon"="D:\\Coding\\Sublime Text 2\\sublime_text.exe,0" @="用Sublime Text &2打开" [HKEY_CLASSES_ROOT\*\shell\Sublime Text\Co

Sublime Text最好的中文教程

原文链接:http://lucida.me/blog/sublime-text-complete-guide/ 摘要(Abstract) 本文系统全面的介绍了Sublime Text,旨在成为最优秀的Sublime Text中文教程. 更新记录 2014/09/27:完成初稿 2014/09/28: 更正打开控制台的快捷键为Ctrl + ` 更正全局替换的快捷键为Ctrl + Alt + Enter 前言(Prologue) Sublime Text是一款跨平台代码编辑器(Code Editor

给sublime text添加ubuntu launcher快捷方式

1.下载sublime text 2文件,解压并复制到/opt目录 2.在/usr/share/applications目录下新建sublime_text.desktop文件 3.文件输入以下内容: [Desktop Entry] Version=2.0 Name=Sublime Text Comment=ST2 Type=Application Categories=Utility; Icon=/opt/Sublime Text 2/Icon/48x48/sublime_text.png Ex

最全面的 Sublime Text 使用指南

最全面的 Sublime Text 使用指南 摘要(Abstract) 本文系统全面的介绍了Sublime Text,旨在成为最优秀的Sublime Text中文教程. 前言(Prologue) Sublime Text是一款跨平台代码编辑器(Code Editor),从最初的Sublime Text 1.0,到现在的Sublime Text 3.0,Sublime Text从一个不知名的编辑器演变到现在几乎是各平台首选的GUI编辑器.而这样优秀的编辑器却没有一个靠谱的中文教程,所以我试图通过本

sublime text全程指南【转载】

前言(Prologue) Sublime Text是一款跨平台代码编辑器(Code Editor),从最初的Sublime Text 1.0,到现在的Sublime Text 3.0,Sublime Text从一个不知名的编辑器演变到现在几乎是各平台首选的GUI编辑器.而这样优秀的编辑器却没有一个靠谱的中文教程,所以我试图通过本文弥补这个缺陷. 编辑器的选择(Editor Choices) 从初学编程到现在,我用过的编辑器有EditPlus.UltraEdit.Notepad++.Vim.Tex

Sublime Text 使用指南

摘要(Abstract) 本文系统全面的介绍了Sublime Text,旨在成为最优秀的Sublime Text中文教程. 更新记录 更正打开控制台的快捷键为Ctrl + ` 更正全局替换的快捷键为Ctrl + Alt + Enter 前言(Prologue) Sublime Text是一款跨平台代码编辑器(Code Editor),从最初的Sublime Text 1.0,到现在的Sublime Text 3.0,Sublime Text从一个不知名的编辑器演变到现在几乎是各平台首选的GUI编