- 浏览: 197171 次
- 性别:
- 来自: 上海
最新评论
-
zhuzhuaijq:
Flash OBJECT和EMBED标签详解 -
matt.u:
好像有点深奥。
一篇比较好演示AS的重构方法 -
luofeng113:
分析得不错,
flex编程感受 -
felixsky:
请问flexunit如何测试private和internal的 ...
FLEXUnit应用 -
wv1124:
你不能分个页啊,看得人都要死了
Apollo: 开发者问答录
For any major project, you couldn't pull me away from classes and an external editor. Nowadays it's Eclipse and Flex Builder. Before that it was FlashDevelop, and before that PrimalScript. In general, I hate coding in the Flash IDE.对于很多的大项目来说,你当然无法将我从编辑器以及类身边抽出来,现在ECLIPSE和FLEX BUILDER就是这样的编辑器,以前那是FLASH DEVELOP PRIMALSCRIPT,然而总的来说我却痛恨在IDE里面编写代码
But often enough, when I'm doing some quick experiment or proof of concept, nothing beats opening up Flash creating a new movie, slamming some code down on the timeline, and pressing Control/Command-Enter. No concern about workspaces and projects. You don't even have to save the damn file. "untitled-1.swf"! Amen!但是通常足够了,当我做一些小的实验来验证某个观念,没有东西能够和创建一部新的影片,在时间轴上写下代码,创建命令按键控制相媲美。不需要考虑工作空间和项目,甚至不需要该死的文件。“未命名-1.swf”
Half the time I do that, that's as far as it goes. But sometimes those quick experiments pan out into something I want to develop further. Then I'm left with the task of scraping that timeline code out of the Actions Panel, and turning it into a class. With my recent Mandelbrot experiment, I realized that there are things you can do to make that conversion process easier, if and when it comes.我一半的时间在做这,当然意义远不止这些,然而有时一些快速的实验可以将我需要进一步开发的东西阐释清楚,那时我便会打开一个AS面版在时间轴上欢快的写起来。关于我最近的MANDBOLERT(分形)实验,我意识到了可以做些事情能够让传统的过程更加容易,如果确实要这样做的话
Most of these go back to good practices I tried to follow way back in AS1 before I was even writing classes, and everything was on the timeline.大多数包含了好的习惯,我想尝试变回咋AS1上开发,所有的编程都围绕时间轴展开
0. All imports right up top.所有的引用要在最右上方【废话】
1. All timeline vars right after imports. Use var, and type your data.所有的时间轴变量在导入语句后申明,使用VAR关键字以及所有的数据
2. ALL code within functions. ALL code. NO stray statements on the timeline. Sometimes when you are just messing around, you'll wind up with a mishmash of functions and statements. Gather up all those loose statements and put them into functions.所有的代码包含在函数里,是的所有的代码,时间轴上没有直接的代码段,如果有时候你确实混乱的不行了,收集那些重复了很多次的代码片段将他们封装成函数【这一点个人感觉很有技术含量的一个事情】
3. All the statements that are just there to set things up go into an init function.所有用来准备的代码封装到INIT函数里
4. Now you are allowed one statement on the timeline itself: init(); The stuff in the init function should be designed to run only once. "init" means "initialize", which means, "set to the value or put in the condition appropriate to the start of an operation". If you find yourself calling init() again, pull some of that stuff out into a "reset" function or something of the sort, and that's what you call multiple times.这样你在时间轴上,只允许一条语句INIT();这里面的代码设计来只运行一次,INIT意味着初始化,如果你的INIT运行了两次,那么抽出那一部分重新组装成RESET()函数
This leaves you with something like this:向下面的代码
PLAIN TEXT
Actionscript:
import flash.display.BitmapData;
import some.other.class;
import some.other.package.*;
var something:SomeType;
var somethingElse:SomeOtherType;
init();
function init():void
{
// body of init
}
function doSomething():void
{
// body
}
function doSomethingElse():void
{
//body
}
That's timeline code, but hell, it's almost starting to look like a class. Not only is it well organized and easy to read, but when the time comes to convert it to a class, there are a few simple steps to get it there:这就是时间轴代码,不仅组织的很好,而且也易于阅读,即使是需要将这些代码转换成类,那么也只需要几个简单的步骤而已
1. Wrap the whole thing in a package statement.将所有的语句包含在包语句里
2. Wrap everything after the imports in a class statement that extends MovieClip or Sprite.在导入语句之后包含类申明,或者是扩展MC类
3. Add indentation to taste.添加标识符
4. Add private to all your vars and functions.为你所有的函数添加private修饰符
5. Wrap the call to init() in a constructor. (Or remove the call to init, and turn the init function into your constructor. I prefer to keep the constructor as just a call to init.)将INIT包裹到构造函数里
6. You might have to add some more imports, as the IDE auto-imports a lot of common stuff.也许你要添加更多的导入语句
If all goes well, you should have a working document class.如果顺利那么通过这些步骤你便得到了一个良好文档的类
http://www.51as.com/as3/BianXieShiJianZhouDaiMaDaiMaGuiFan/
But often enough, when I'm doing some quick experiment or proof of concept, nothing beats opening up Flash creating a new movie, slamming some code down on the timeline, and pressing Control/Command-Enter. No concern about workspaces and projects. You don't even have to save the damn file. "untitled-1.swf"! Amen!但是通常足够了,当我做一些小的实验来验证某个观念,没有东西能够和创建一部新的影片,在时间轴上写下代码,创建命令按键控制相媲美。不需要考虑工作空间和项目,甚至不需要该死的文件。“未命名-1.swf”
Half the time I do that, that's as far as it goes. But sometimes those quick experiments pan out into something I want to develop further. Then I'm left with the task of scraping that timeline code out of the Actions Panel, and turning it into a class. With my recent Mandelbrot experiment, I realized that there are things you can do to make that conversion process easier, if and when it comes.我一半的时间在做这,当然意义远不止这些,然而有时一些快速的实验可以将我需要进一步开发的东西阐释清楚,那时我便会打开一个AS面版在时间轴上欢快的写起来。关于我最近的MANDBOLERT(分形)实验,我意识到了可以做些事情能够让传统的过程更加容易,如果确实要这样做的话
Most of these go back to good practices I tried to follow way back in AS1 before I was even writing classes, and everything was on the timeline.大多数包含了好的习惯,我想尝试变回咋AS1上开发,所有的编程都围绕时间轴展开
0. All imports right up top.所有的引用要在最右上方【废话】
1. All timeline vars right after imports. Use var, and type your data.所有的时间轴变量在导入语句后申明,使用VAR关键字以及所有的数据
2. ALL code within functions. ALL code. NO stray statements on the timeline. Sometimes when you are just messing around, you'll wind up with a mishmash of functions and statements. Gather up all those loose statements and put them into functions.所有的代码包含在函数里,是的所有的代码,时间轴上没有直接的代码段,如果有时候你确实混乱的不行了,收集那些重复了很多次的代码片段将他们封装成函数【这一点个人感觉很有技术含量的一个事情】
3. All the statements that are just there to set things up go into an init function.所有用来准备的代码封装到INIT函数里
4. Now you are allowed one statement on the timeline itself: init(); The stuff in the init function should be designed to run only once. "init" means "initialize", which means, "set to the value or put in the condition appropriate to the start of an operation". If you find yourself calling init() again, pull some of that stuff out into a "reset" function or something of the sort, and that's what you call multiple times.这样你在时间轴上,只允许一条语句INIT();这里面的代码设计来只运行一次,INIT意味着初始化,如果你的INIT运行了两次,那么抽出那一部分重新组装成RESET()函数
This leaves you with something like this:向下面的代码
PLAIN TEXT
Actionscript:
import flash.display.BitmapData;
import some.other.class;
import some.other.package.*;
var something:SomeType;
var somethingElse:SomeOtherType;
init();
function init():void
{
// body of init
}
function doSomething():void
{
// body
}
function doSomethingElse():void
{
//body
}
That's timeline code, but hell, it's almost starting to look like a class. Not only is it well organized and easy to read, but when the time comes to convert it to a class, there are a few simple steps to get it there:这就是时间轴代码,不仅组织的很好,而且也易于阅读,即使是需要将这些代码转换成类,那么也只需要几个简单的步骤而已
1. Wrap the whole thing in a package statement.将所有的语句包含在包语句里
2. Wrap everything after the imports in a class statement that extends MovieClip or Sprite.在导入语句之后包含类申明,或者是扩展MC类
3. Add indentation to taste.添加标识符
4. Add private to all your vars and functions.为你所有的函数添加private修饰符
5. Wrap the call to init() in a constructor. (Or remove the call to init, and turn the init function into your constructor. I prefer to keep the constructor as just a call to init.)将INIT包裹到构造函数里
6. You might have to add some more imports, as the IDE auto-imports a lot of common stuff.也许你要添加更多的导入语句
If all goes well, you should have a working document class.如果顺利那么通过这些步骤你便得到了一个良好文档的类
http://www.51as.com/as3/BianXieShiJianZhouDaiMaDaiMaGuiFan/
发表评论
-
pv3d学习资料
2009-08-13 14:54 1821官方网站 http://www.papervision3d.c ... -
Flash客户端间的交互
2009-08-13 14:35 3026Flash有着天生非凡的动画和交互能力, 在RIA (富互联网 ... -
ItemRenderer的用法
2009-01-14 13:59 1765项目渲染器(ItemRenderer ... -
Flex3组件拖放教程
2008-08-27 16:27 2446关于组件拖放 可视化的开发环境就是要允许用户能够在屏幕中通过鼠 ... -
基于MVC的Flex framework比较
2008-08-13 10:13 1552关键字: mvc framework 原文出处:[url]h ... -
色彩模式(RGB、CMYK、HSB、Lab、Duotone等)
2008-08-05 13:10 3736色彩是一门很深的学问,每种色彩都有自己的特点和原理。设计师要在 ... -
colormatrixFilter
2008-07-31 12:38 1098http://hi.baidu.com/fmz1206/blo ... -
使用BlazeDS实现Java和Flex通信
2008-06-16 09:21 1015http://blog.chinaunix.net/u/216 ... -
amf是什么东东
2008-06-12 16:59 1306今天我们开发的 J2EE 网 ... -
Flash特效制作常用的源代码大放送
2008-06-06 16:02 1046对象数组 比如要构建一个有很多属性的数组,简单的可以这样 ... -
关于ApplicationDomain的一些理解
2008-06-05 17:07 2813应用程序域: 允许跨域加载swf后,还可能出现加载的swf中的 ... -
Flash OBJECT和EMBED标签详解
2008-06-05 17:03 31063Flash OBJECT和EMBED标签 一 ... -
flex的一些项目
2008-06-03 14:48 1290一些Flex开源项目的整理 Adobe APIs 主要包 ... -
flex模式(转载)
2008-06-03 14:28 1500[url] http://www.awflasher.com/ ... -
programming Flex2 学习笔记-第5章-框架基础.txt (转载的,来自)
2008-05-29 10:40 1235来自http://blog.chinaunix.net ... -
给DataGrid设置背景色(汇总)
2008-05-27 16:49 4981DataGrid颜色专题 在Flex运用中经常提到的有关 ... -
通过ApplicationDomain类获得被加载应用程序域
2008-05-27 13:32 1611首先先回顾一下FLASH的OO ... -
一些Flex / Flash开源项目
2008-05-09 14:26 1513Adobe APIs 主要包含corelib, ... -
这几个网站是我经常去的,做开发时可以参考
2008-05-09 14:14 1367http://www.flashas.net/ http:// ... -
108种Flash常见问题解答(收藏别的:站名:http://www.flashas.net/)
2008-05-09 14:09 23791. 论坛上常说的MC、FS、 ...
相关推荐
2 2 VHDL代码编写规范 4 2 2 1 信号命名法 4 2 2 2 模块命名法 5 2 2 3 程序书写格式 5 2 2 4 测试向量的编写 8 2 2 5 代码编写风格 11 2 3 测试报告 24 3 XILINX FPGA设计规范 26 3 1 VERTEX2提供的资源 26 3 1 1 ...
JAVA+JSP的聊天室 8个目标文件 简单 JavaScript万年历 显示出当前时间及年份,还可以选择年份及月份和日期 Java编写的HTML浏览器 一个目标文件 摘要:Java源码,网络相关,浏览器 Java编写的HTML浏览器源代码,一个很...
《Android应用开发揭秘》全部实例源代码,配合《Android应用开发揭秘》使用 前言 第一部分 准备篇 第1章 Android开发简介 1.1 Android基本概念 1.1.1 Android简介 1.1.2 Android的系统构架 1.1.3 ...
用JAVA编写的指针式圆形电子钟,效果图如下所示,其实代码很简单,希望对你有帮助。 Message-Driven Bean EJB实例源代码 2个目标文件 摘要:Java源码,初学实例,EJB实例 Message-Driven Bean EJB实例源代码,演示...
∗ 精准的策略回测,用户可以实时下载每日行情数据并保存,在此数据基础上,基于TICK或分钟K线进行不同时间周期的策略回测。采用图形复盘和日志记录的方式,让用户精确到每一个时点来核对策略及指标的有效性,将策略...
4.6.3 编写ctermdoc类的相关代码 132 4.6.4 小结 141 4.6.5 在ctermview类中字添加符键入处理代码与串口接收处理代码 142 第5章 串口调试助手v2.2编程 147 5.1 建立scomm程序工程实现界面功能 147 5.2 串口的...
实例70 求方阵对角线之和 96 实例71 矩阵的加法 97 实例72 矩阵的减法 98 实例73 快递报价单 99 5.3 数组的排序 101 实例74 冒泡排序法 102 实例75 数组递增排序 103 实例76 部分数组...
SimpleCache 是一个简单易用的java缓存工具,用来简化缓存代码的编写,让你摆脱单调乏味的重复工作!1. 完全透明的缓存支持,对业务代码零侵入 2. 支持使用Redis和Memcached作为后端缓存。3. 支持缓存数据分区规则的...
SimpleCache 是一个简单易用的java缓存工具,用来简化缓存代码的编写,让你摆脱单调乏味的重复工作!1. 完全透明的缓存支持,对业务代码零侵入 2. 支持使用Redis和Memcached作为后端缓存。3. 支持缓存数据分区规则的...
第3章 html文档的编写规范 3.1 使用标签、元素和属性 3.1.1 标签 3.1.2 元素 3.1.3 属性的定义 3.1.4 属性值的定义 3.1.5 元素和属性的大小写规范 3.2 字符引用 3.2.1 字符数字引用 3.2.2 字符实体引用 3.3 使用注释...
4.12 时间服务及任务的挂起和恢复 4.13 获取当前Small RTOS51的版本号 4.14 OSInt…()函数 第5章 如何切换任务 5.1 CPU可以执行多个任务的原因 5.2 CPU怎样运行才能执行多个任务 5.3 何时进行任务切换 5.4 Small...
1.软件有规划专业人员编写,与规划设计规范的结合紧密:软件的使用可以使规划院的图纸标准化和规范化。(在线性、颜色、图层、图则、风玫瑰、图例等方面都可以按规划院的标准统一定制使用) 2.软件自动化程度很高...
jQuery 1.4(2010年1月14号对)代码库进行了内部重写组织,开始建立一些风格规范。老的core.js文件被分为attribute.js, css.js, data.js, manipulation.js, traversing.js和queue.js;CSS和attribute的逻辑分离。 ...
2.可读性:代码编写是否规范,是否便于阅读。如函数、变量命名,‘{ }’的缩进,关键位置适量注释等 3.功能的完善:除要求实现的功能外,完成了其它的功能,实现了功能的完善 4.健壮性:异常处理的情况 5.界面的设计...
RTL代码编写的规则 通用规则 VHDL设计规则 Venlog设计规则 使用HDL检查工具对RTL设计规则进行检查 RTL级设计与综合及后端设计的关系 RTL级设计的综合结果 在RTL编码中考虑时延 在RTL编码中考虑面积问题 在RTL编码中...
1、边框线 属性:border: 取值: 2、边框倒角 属性:border-radius: 取值: px % 3、边框阴影 属性:box-shadow: 取值: inset h-shadow v-shadow blur spread color; 1、 h-shadow:阴影的水平偏移距离 px ...
2.4. 上传程序开发规范 2.5. 插件开发指南 2.6. 皮肤设计指南 2.7. 关于二次开发 2.1. 进阶使用指导 阅读本章节请先阅读:xhEditor入门基础,若你已经熟悉xhEditor的基本使用,请往下继续。 xhEditor提供两种方式...
SimpleCache 是一个简单易用的java缓存工具,用来简化缓存代码的编写,让你摆脱单调乏味的重复工作!1. 完全透明的缓存支持,对业务代码零侵入 2. 支持使用Redis和Memcached作为后端缓存。3. 支持缓存数据分区规则的...