September 9th, 2007
下载swf文件:focuswing_1.0.rar
下载exe文件:focuswing_1.0.exe
采用as3,mvc模式开发。刚开始不习惯这种模式,用多了突然会觉得很顺手。
饭否:应该就不用介绍了吧
AsWing:aswing是一个开源的flash GUI框架,布局和架构思路类似javaswing。之前的A2版本由于只支持mtasc编译方式,所以在配置和使用上都略显复杂。不过目前的A3版本既可以支持Flex开发,也支持Flash编译方式开发,配置和使用几乎没有门槛。
更值得说一下的是,这个框架是由国人自己开发的,在国内这样的互联网环境下能有这样始终保持生命力的开源项目诞生和存在,还是满有意义的。
一直认为flex的组件以及mxml的编写方式局限性很大。虽然AsWing与flex的组件不具有可比性。不过AsWing显然提供了一种更为纯净的方式来使用as3。
Posted in 作品 | 4 Comments »
August 17th, 2007
as2时代直接在dispatchEvent的时候跟上想跟的参数就可以了,as3增加了一个Event的继承类来承担其中的信息传递,不过看书看到关键时刻居然就没有了。于是笔记一下类实例怎么向外发送事件和传递参数,来点实用的。
发送事件的Guest,在Guest内发送”do_b”的Event:
- var e:GuestEvent = new GuestEvent(GuestEvent.DO_B);
- e.args = {author:"hirokimo",time:"21:10"};
- this.dispatchEvent(e);
这时候为了传递参数,使用一个继承Event的自定义事件类GuestEvent:
- package
- {
- import flash.events.Event;
- public class GuestEvent extends Event
- {
- public static const DO_A:String = "do_a";
- public static const DO_B:String = "do_b";
- public static const DO_C:String = "do_c";
- public var args:*;
- public function GuestEvent(_type:String)
- {
- super(_type);
- }
- }
- }
最后,在类外面添加侦听和接收的地方:
- package
- {
- public class EventTest
- {
- public function EventTest()
- {
- var guest:Guest = new Guest();
- guest.addEventListener(GuestEvent.DO_B,handleB);
- }
- private function handleB(e:GuestEvent):void
- {
- trace("author:"+e.args.author
- +" time:"+e.args.time);
- //author:hirokimo time:21:10
- }
- }
- }
大功告成,之后就可以顺利的发送事件参数了。
不过有一点值得注意:Guest类里有时需要在初始化后直接dispatch一个Event出来,这时候因为外部addEventListener动作还没有完成,listener是收不到事件的。
这个问题很容易被忽略,如果一定要这么做,可以:
1.Guest初始化后timer几百毫秒再dispatch 或者
2.外面addEventListener完之后,主动调guest.xxx来发送。
Posted in flash | No Comments »
August 5th, 2007
仅仅是笔记 没有讨论问题 大家请略过
1.用正则来replace字符串
- var str:String = "above thE cloud,around The shadow.";
- var pattern:RegExp = /the/ig;
- trace(str.replace(pattern, "my"));
- //above my cloud,around my shadow.
2.数组深度copy
- private function clone(source:Object):*
- {
- var myBA:ByteArray = new ByteArray();
- myBA.writeObject(source);
- myBA.position = 0;
- return(myBA.readObject());
- }
3.遍历Object,这个和as3没什么关系,不过经常用到。
- private function traceObject(obj:Object, indent:uint = 0):void
- {
- var indentString:String = "";
- var i:uint;
- var prop:String;
- var val:*;
- for (i = 0; i < indent; i++)
- {
- indentString += "\t";
- }
- for (prop in obj)
- {
- val = obj[prop];
- if (typeof(val) == "object")
- {
- trace(indentString + " " + prop + ": [Object]");
- traceObject(val, indent + 1);
- }
- else
- {
- trace(indentString + " " + prop + ": " + val);
- }
- }
- }
Posted in flash | No Comments »
July 29th, 2007
一直在找借口,要等到fdt3出来后才开始学as3,没想到fdt3的alpha就已经出来了-_-,下载了后总的来说,感觉已经失去了as2时代的优势了,抛开没有好的一个trace机制来说,flex builder的功能也完全可以取代之了。
不过还是会一直用它来写as2代码,卡卡。
关于fb3beta,试用感觉还不错,把快捷debug设置设成和flash里一样,然后在调试台里看信息。其实和写java的感觉差不多,怪不得java程序员那么容易上手as3-_-。
关于怎么设置的和flash里一样手感,可以参照eidiot同学的文章。
here:使用Flex Builder开发AS3程序
然后,总算可以开始了,虽然总比别人慢一拍。
至于flex组件和mxml编码方式,暂时不打算涉及,这种编码方式实在是满奇怪的。
Posted in flash | No Comments »
July 1st, 2007
下载地址
或者有需要swf文件直接用的朋友:fanflash-13-pro.rar(35k)
[由于flash安全问题在本地无法工作,需要传到网上.]
主要改进:
1.之前一直有朋友提议记住密码,可能我误会了大家的意思,现在不用每次输密码了-_-,当然重新开以后还是要输入一次得。
2.之前输入id的流程不太合理,感觉很麻烦,现在可以在客户端记住id,发信息使用当前id。当然,增加了更改id的选项,满足马甲狂人的需要。

3.重大改进,发信息时可以选择@好友。因为平时给好友@信息比较麻烦,尤其是昵称有中文和奇怪字符的好友。

4.修正了些bug…最后还是要谢谢大家留的建议.
Posted in 作品 | 4 Comments »
June 17th, 2007
下载地址:fanflash-beta-1.2.exe
周末忙里偷闲做了这个东西出来,主要就是觉得饭否在同类站点里很有亲和力,可以明显看到团队的力量。而且比twitter稳定,希望他们越发展越好。主要功能:
1.发信息
2.看我的文章
3.看我和好友的文章(可刷新)
4.看好友列表
5.随便看看(可刷新)
其实就是api开发出来的几条功能,呵呵 -_-


mine:hirokimo
相当热爱互联网的同事:guke
Posted in 作品 | No Comments »
May 26th, 2007
刚开始使用 setInterval 和 clearInterval 的时候,总是会被脱僵状态困扰。就是说,明明有时候将 intervalID给清理掉了,原来定义的间隔还是不停的执行着,具体的内容可以看aw同学的分析,讲的非常清晰了。于是为了避免出现未预期的程序问题,通常只好使用onEnterFrame来替代。
不过在单纯继承于Object,仅仅处理逻辑的类中,没有MovieClip来充当onEnterFrame的载体,为了创建interval还是要用到 setInterval 方法才行(除非你传一个MovieClip对象进来当holder)。于是参照分析中interval进出栈的做法,封装成一个Interval 类,使用起来就万无一失了。
- class Interval {
- private var intervals : Array;
- private var interval : Number;
- public function Interval(obj : Object, func : String, time : Number) {
- intervals = new Array();
- interval = setInterval(obj, func, time);
- intervals.push(interval);
- }
- public function clearIntervals() : Void {
- for (var i in intervals) {
- clearInterval(intervals[i]);
- intervals.pop();
- }
- clearInterval(interval);
- }
- public function toString() : String{
- return "[object interval]";
- }
- }
调用:var x:Interval = new Interval(owner, “doSth”,500);
清除:x.clearIntervals();
Posted in flash | No Comments »
May 3rd, 2006
具体用法需要研究的同学看三个public入口就知道了。
- /**
- * @author hirokimo
- * @data 2006-05-03
- * @usage A*path searching
- */
- class Astar {
- private static var cost:Number = 10;
- private static var isSearching:Boolean = false;
- private static var broadcastInit = AsBroadcaster.initialize(Astar.prototype);
- public var addListener:Function;
- public var removeListener:Function;
- private var broadcastMessage:Function;
- private var path:Array;
- private var openList:Array;
- private var closeList:Array;
- private var map:Array;
- private var pointType:Array;
- private var directData:Array;
- //
- public function Astar() {
- path = new Array();
- pointType = new Array();
- openList = new Array();
- closeList = new Array();
- directData = new Array();
- map = new Array();
- initDirectData();
- }
- public function setMap(map_t:Array) {
- map = map_t;
- setPointType(map);
- }
- public function findPath(startX:Number, startY:Number, endX:Number, endY:Number) {
- initData();
- isSearching = true;
- var startPoint:Object = new Object();
- var endPoint:Object = new Object();
- var prePoint:Object = new Object();
- startPoint.X = startX;
- startPoint.Y = startY;
- endPoint.X = endX;
- endPoint.Y = endY;
- startPoint.parent = null;
- startPoint.G = 0;
- startPoint.H = manhattanDis(startPoint, endPoint);
- startPoint.F = startPoint.G+startPoint.H;
- prePoint = startPoint;
- //send2List(startPoint, openList);
- send2List(startPoint, closeList);
- while (isSearching == true) {
- for (var i = 0; i<directData.length; i++) {
- var tempPoint:Object = new Object();
- tempPoint.X = prePoint.X+directData[i][0];
- tempPoint.Y = prePoint.Y+directData[i][1];
- if (isOut(tempPoint) == true) {
- } else {
- if (tempPoint.Y == endPoint.Y && tempPoint.X == endPoint.X) {
- //found
- isSearching = false;
- send2List(tempPoint, closeList);
- tempPoint.parent = prePoint;
- tempPoint.G = prePoint.G+directData[i][2];
- tempPoint.H = manhattanDis(tempPoint, endPoint);
- tempPoint.F = tempPoint.G+tempPoint.H;
- //trace(closeList[closeList.length-1].X+" "+closeList[closeList.length-1].Y);
- //trace("path found!");
- drawPath();
- broadcastMessage("onPathFound");
- return;
- }
- if (getPointType(tempPoint) == "road" && isInList(tempPoint, closeList) == false) {
- //trace("四向之"+i+" tempPoint:"+tempPoint.X+" "+tempPoint.Y);
- //目标格不在关闭列表且是road
- if (isInList(tempPoint, openList) == false) {
- //目标格尚未开启
- send2List(tempPoint, openList);
- //trace("ol:"+openList[0].X+"=="+openList[0].Y);
- tempPoint.parent = prePoint;
- tempPoint.G = prePoint.G+directData[i][2];
- tempPoint.H = manhattanDis(tempPoint, endPoint);
- tempPoint.F = tempPoint.G+tempPoint.H;
- } else {
- //已经在开启列表中
- var tempG:Number = prePoint.G+directData[i][2];
- for (var j = 0; j<openList.length; j++) {
- if (tempPoint.X == openList[j].X && tempPoint.Y == openList[j].Y) {
- if (tempG<openList[j].G) {
- //现在的路径G更好
- openList[j].G = tempG;
- openList[j].F = openList[j].G+openList[j].H;
- openList[j].parent = prePoint;
- }
- break;
- }
- }
- }
- }
- }
- }
- if (openList.length == 0) {
- isSearching = false;
- broadcastMessage("onPathBlock");
- return;
- }
- sortList(openList);
- prePoint = openList.shift();
- send2List(prePoint, closeList);
- //trace(closeList[closeList.length-1].X+" "+closeList[closeList.length-1].Y);
- }
- }
- public function getPath():Array {
- path.reverse();
- trace("==========Path start===========");
- for (var i = 0; i<path.length; i++) {
- trace("path:"+path[i].X+path[i].Y);
- }
- trace("==========Path end ===========");
- return path;
- }
- private function initData():Void {
- openList = [];
- closeList = [];
- path = [];
- }
- private function drawPath() {
- //trace("set path");
- closeList.reverse();
- var currentPathPoint:Object = new Object();
- currentPathPoint = closeList[0];
- send2List(currentPathPoint, path);
- //trace(currentPathPoint.X+" "+currentPathPoint.Y);
- for (var i = 1; i<closeList.length; i++) {
- if (currentPathPoint.parent == null) {
- break;
- }
- //trace(currentPathPoint.parent.X+" "+currentPathPoint.parent.Y);
- send2List(currentPathPoint.parent, path);
- currentPathPoint = currentPathPoint.parent;
- }
- }
- private function getPointType(point_t:Object):String {
- return pointType[point_t.X][point_t.Y];
- }
- private function setPointType(map_t:Array) {
- for (var i = 0; i<map_t.length; i++) {
- pointType[i] = new Array();
- for (var j = 0; j<map_t[0].length; j++) {
- if (map_t[i][j] == 1) {
- pointType[i].push("wall");
- } else if (map_t[i][j] == 0) {
- pointType[i].push("road");
- }
- }
- }
- //trace("第一行:"+pointType[0]);
- }
- private function initDirectData():Void {
- //下,右,上,左
- directData[0] = [1, 0, 10];
- directData[1] = [0, 1, 10];
- directData[2] = [-1, 0, 10];
- directData[3] = [0, -1, 10];
- }
- private function sortList(list_t:Array):Void {
- list_t.sortOn("F", Array.NUMERIC);
- }
- private function isOut(point_t:Object):Boolean {
- if (point_t.X<0 || point_t.Y<0 || point_t.X>16 || point_t.Y>16) {
- return true;
- } else {
- return false;
- }
- }
- private function isInList(point_t:Object, list_t:Array):Boolean {
- if (list_t.length == 0) {
- return false;
- }
- for (var i = 0; i<list_t.length; ) {
- if (list_t[i].X == point_t.X && list_t[i].Y == point_t.Y) {
- return true;
- break;
- }
- i++;
- if (i == list_t.length) {
- return false;
- }
- }
- }
- private function manhattanDis(start_t:Object, end_t:Object):Number {
- var dis:Number;
- dis = Math.abs(start_t.X-end_t.X)+Math.abs(start_t.Y-end_t.Y);
- return dis*cost;
- }
- private function send2List(point_t:Object, list_t:Array):Void {
- list_t.push(point_t);
- }
- }
Posted in flash | No Comments »