首页 技术 正文
技术 2022年11月12日
0 收藏 302 点赞 2,397 浏览 4354 个字

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

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,031
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,520
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,368
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,148
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,781
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,860