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

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

  1. kali linux 2.0安装sublime text 2

    第一种方法:Download the Sublime Text 2 & Extract it:32位:$ wget http://c758482.r82.cf2.rackcdn.com/Sub ...

  2. Sublime Text 全程指引 by Lucida

    作者:Lucida 微博:@peng_gong 豆瓣:@figure9 博客园:@figure9 原文链接:http://zh.lucida.me/blog/sublime-text-complete ...

  3. centos6.5安装sublime text 2

    今天在看ueillemmx的博客的时候,看到一神级编辑器,随即安装试了试,我了个去,果然好用,自动补全,自动对齐,样样精通啊! 下面是根据ueillemmx的步骤在CentOS上安装Sublime的过 ...

  4. Sublime Text 全程指南

    摘要(Abstract) 本文系统全面的介绍了 Sublime Text,旨在成为最优秀的 Sublime Text 中文教程. 更新记录 2014/09/27:完成初稿 2014/09/28: 更正 ...

  5. Sublime Text使用教程【转】

    本文转载自:http://lucida.me/blog/sublime-text-complete-guide/ 摘要(Abstract) 本文系统全面的介绍了 Sublime Text,旨在成为最优 ...

  6. 右键菜单添加程序,指定图标, Notepad2、Sublime Text 2

    右键添加Sublime Text 打开方式 Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell\Sublime Text] ...

  7. [笔记]--Ubuntu安装Sublime Text 2

    sublime text 2 有两种安装方式,一种是添加软件源,然后用命令安装.另外一种是下载安装包.解压手动安装.Sublime Text 2 入门及技巧 一.下载安装 1.在Sublime Tex ...

  8. 给sublime text添加ubuntu launcher快捷方式

    1.下载sublime text 2文件,解压并复制到/opt目录,文件夹名称不要含有空格 2.在/usr/share/applications目录下新建sublime_text.desktop文件 ...

  9. ubuntu 下添加sublime text 启动图标

    ubuntu下无快捷方式一说,如果想快速打开sublime Text,可以创建sublime text 启动图标 1. 创建空白文档 sublime.desktop,注意权限 $ vi /usr/sh ...

随机推荐

  1. CreateDialog 注意事项

    CreateDialog创建非模态对话框时 其内部 会发送几条消息例如: WM_INITDIALOG,WM_SETFONT  DS_SETFONT , DS_SHELLFONT. 所以如果在另一个Ca ...

  2. ubuntu 连接windows远程桌面 &&rdesktop 退出全屏模式

    参考:http://www.asgone.net/ubuntu-connect-windows-remote-desktop/ 呵呵,使用上了ubuntu,怎么接连上我的服务器的远程桌面呢,找了找帮助 ...

  3. 【LeetCode】4. Median of Two Sorted Arrays (2 solutions)

    Median of Two Sorted Arrays There are two sorted arrays A and B of size m and n respectively. Find t ...

  4. IT软件外包行业深入分析:现状、前途、趋势、待遇 什么是软件外包 外包公司是怎么工作的 软件外包公司的面试 软件外包公司需要什么样的人

    目录: [0] - 为什么要对大学生谈软件外包? [1] - 什么是软件外包? [2] - 软件为什么要外包? [3] - 为什么要承接软件外包 [4] - 做软件外包有前途吗? [5] - 外包公司 ...

  5. 树莓派进阶之路 (012) - 关于Raspberry Pi树莓派无线网卡配置

    Raspberry Pi树莓派无线网卡配置[多重方法备选] 要想让树莓派方便操作,肯定需要配置无线网卡,这样可以大大增强树莓派的移动性和便利性,其实配置无线网卡基本就是和普通linux平台下配置无线网 ...

  6. HDU 4607 Park Visit (树的最长链)

    Park Visit Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  7. MySQL安装Altas

    准备工作:需要先把MySQL主从配置好. 0.下载altas:打开https://github.com/Qihoo360/Atlas/releases wget https://github.com/ ...

  8. IT系统故障引起的一个事故的思考

    记得几年前在我以前工作过的一个公司,因为系统的一个审批流突然中断,而且也没有在系统中触发邮件和短信等提示消息,而且我们的相关的审批人员和发 起人也没有在意.直到流程发起的同事在采购物品即将要使用的前2 ...

  9. 跟我学SharePoint 2013视频培训课程—— 版本控制以及内容审批(14)

    课程简介 第14天,怎样在SharePoint 2013中启用版本控制以及内容审批 视频 SharePoint 2013 交流群 41032413

  10. 第二篇:呈现内容_第二节:WebControl呈现

    一.WebControl的呈现过程 WebControl派生自Control类,所以WebControl的呈现功能基于Control的呈现逻辑之上,但有了比较大的扩展. 首先,WebControl重写 ...