DFdou's Blog Life is short,Be yourself.

3010/092

AS3-getDefinitionByName

先来看下CS3版F1的介绍:

public function getDefinitionByName(name:String):Object
语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9
返回 name 参数指定的类的类对象引用。
参数 name:String — 类的名称。
返回 Object — 返回 name 参数指定的类的类对象引用。
引发 ReferenceError — 不存在具有指定名称的公共定义。

下边是一个读取地图信息并显示的实例。文件有点多,先来看主文档,TD.as:

package{
	import flash.display.Sprite;
	import org.nwhy.TD.Config;
	import org.nwhy.TD.Controller;
	public class TD extends Sprite{
		public var screen:Sprite;
		public function TD(){
			screen = new Sprite();
			addChild(screen);
			var game:Controller = new Controller(screen,new Config());
		}
	}
}
2910/090

常用的几个正则表达式

以下内容来自网络,版权不明哈哈。
^\d+$  //匹配非负整数(正整数 + 0)
^[0-9]*[1-9][0-9]*$  //匹配正整数
^((-\d+)|(0+))$  //匹配非正整数(负整数 + 0)
^-[0-9]*[1-9][0-9]*$  //匹配负整数
^-?\d+$    //匹配整数
^\d+(\.\d+)?$  //匹配非负浮点数(正浮点数 + 0)
^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$  //匹配正浮点数
^((-\d+(\.\d+)?)|(0+(\.0+)?))$  //匹配非正浮点数(负浮点数 + 0)
^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$  //匹配负浮点数
^(-?\d+)(\.\d+)?$  //匹配浮点数
^[A-Za-z]+$  //匹配由26个英文字母组成的字符串
^[A-Z]+$  //匹配由26个英文字母的大写组成的字符串
^[a-z]+$  //匹配由26个英文字母的小写组成的字符串
^[A-Za-z0-9]+$  //匹配由数字和26个英文字母组成的字符串
^\w+$  //匹配由数字、26个英文字母或者下划线组成的字符串
^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$    //匹配email地址
^[a-zA-z]+://匹配(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$  //匹配url

匹配中文字符的正则表达式: [\u4e00-\u9fa5]
匹配双字节字符(包括汉字在内):[^\x00-\xff]
匹配空行的正则表达式:\n[\s| ]*\r
匹配HTML标记的正则表达式:/< (.*)>.*< \/>|< (.*) \/>/
匹配首尾空格的正则表达式:(^\s*)|(\s*$)
匹配Email地址的正则表达式:\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
匹配网址URL的正则表达式:^[a-zA-z]+://(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$
匹配帐号是否合法(字母开头,允许5-16字节,允许字母数字下划线):^[a-zA-Z][a-zA-Z0-9_]{4,15}$
匹配国内电话号码:(\d{3}-|\d{4}-)?(\d{8}|\d{7})?
匹配腾讯QQ号:^[1-9]*[1-9][0-9]*$

2810/090

AIR2特性

内容来自http://flash.9ria.com/thread-38710-1-1.html,多谢joesonwong的翻译哈。

这个早上,我准备用AIR2.0里面的一些新特性做一个视频DEMO时,我意识到我可能要从一堆全新的东西着手.下面是一份全面的关于准备要出现在AIR2.0中的新特性的列表.我用这个词准备是因为即使在相对比较新的平台上,东西也将可能改变.

多点触摸 触摸事件将会和鼠标事件类似,但是只是在支持多点触摸的设备上.同时,你也可以捕捉这些触摸点.
需求:
WINDOWS7或更高
支持多点触摸的硬件(显然地)
手势 应用程序可以监听多点触摸事件或手势事件,但不能同时.手势是所有多点触摸事件的一个集合的单独的类.
需求:
WINDOWS7或更高
有多点触摸板的MAC 10.6或更高.
支持的手势:
GESTURE_TWO_FINGER_TAP(敲击两个手指)
GESTURE_PRESS_AND_TAP(按住一个手指,另一个手指敲击,为了方便一些WINDOWS的设备调出菜单
通过默认关联程序打开文件:这个新的File.openWithDefaultApplicationAPI允许你通过文件的关联应用程序打开文件.这是一个极好的跨平台的方式.这样可以极好的整合其他应用程序如果你不知道该文件的默认关联程序.
操作系统下载安全对话:这个新的File.downloaded属性能让你知道当前正在从网络下载文件,而且操作系统会打开一个确认对话框来让用户决定是否打开这个文件.

Tagged as: Continue reading
2710/091

AS3-如何加载自身SWF

先看Demo,顺便介绍下MP3切割工具一枚"mp3spliter",再顺便鄙视下PR被降权了……


我们来看一下代码:

stop();
var tf_loadinfo:TextField = new TextField();
tf_loadinfo.autoSize = TextFieldAutoSize.CENTER;
tf_loadinfo.selectable=false;
tf_loadinfo.background = true;
var format:TextFormat = new TextFormat();
format.font = "Arial";
format.size = 12;
tf_loadinfo.defaultTextFormat = format;
addChild(tf_loadinfo);
root.loaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress);
root.loaderInfo.addEventListener(Event.COMPLETE, loadComplete);
function loadComplete(_e:Event):void {
	removeChild(tf_loadinfo);
	play();
}
function showProgress(_e:ProgressEvent):void {
	var p:Number=_e.bytesLoaded/_e.bytesTotal;
	var n:Number=Math.round(p*100);
	tf_loadinfo.text='Loading '+n.toString()+'%';
	setCenter(tf_loadinfo);
}
function setCenter(obj:Object) {
	obj.x =(stage.stageWidth-obj.width)/2;
	obj.y =(stage.stageHeight-obj.height)/2;
}
2610/090

AS3-如何让TextField鼠标出现手形?

这个问题来自http://flash.9ria.com/thread-25870-1-1.html
我以前的处理方法是放空MC,也就是4楼的做法:

import flash.events.MouseEvent;
var txt:TextField = new TextField();
txt.text = "wonderful";
txt.x=200;
txt.y=200;
txt.autoSize = TextFieldAutoSize.LEFT;
addChild(txt);
var format:TextFormat = new TextFormat("Arial",30,0x9900000);
txt.setTextFormat(format);
var mc:Sprite = new Sprite();
mc.graphics.beginFill(0x000000,0);
mc.graphics.drawRect(txt.x,txt.y,txt.textWidth,txt.textHeight);
mc.buttonMode = true;
addChild(mc);

6楼的做法也不错,不过问题是这只能用在CS4里,CS3还不支持~

mytx.addEventListener(MouseEvent.MOUSE_OVER,mousesj1);
mytx.addEventListener(MouseEvent.MOUSE_OUT,mousesj2);
function mousesj1(e:MouseEvent) {
        Mouse.cursor="button";       //当鼠标移到动态文本上时出现手形
}
function mousesj2(e:MouseEvent) {
        Mouse.cursor="arrow";        //当鼠标离开动态文本时取消手形,恢复为箭头
}
2310/090

13+ CSS Editor Help You Create Perfect Website

Learned from http://ntt.cc/2009/10/29/13-hand-picked-css-editor-help-you-create-perfect-website.html
我只用过Firebug呵呵,针对CSS的编辑器还真么用过,个人觉得Firebug+手写比较方便=。=
下边是作者介绍的13+个编辑器,总的来说嘛就是傻瓜式样式选择,我也没测试过,不知道生成的CSS代码规范性如何。
Astyle CSS editor


Astyle is a visual CSS editor. Features:

  • Visual easy-to-use interface
  • Graphic tree-type view of attachment files and the CSS structure
  • Grouped view of properties and selectors
  • Automatic selection and grouping of CSS selectors from a markup language document
  • Source CSS, HTML, XML highlight code editor
  • Active preview current selectors and documents with IE and Mozilla supportAstyle
    不推荐,没别的,界面难看嘿嘿。
  • 2210/090

    jQuery Plugins-SimpleModal弹窗插件

    官方地址:http://www.ericmmartin.com/projects/simplemodal-demos/. 内容简单明了,如下哈:

    The following demos are intended to illustrate the flexibility of SimpleModal.

    Note: The Contact Form demo needs to be run from a web server and requires PHP.

    Download SimpleModal SimpleModal Project Page

    Basic Modal Dialog

    A basic modal dialog with minimal styling and without any additional settings. There are a few CSS attributes set internally by SimpleModal, however, SimpleModal relies mostly on external CSS for the look and feel.

    Demo Download

    Contact Form

    A contact form built on SimpleModal. Demonstrates the use of the onOpen, onShow and onClose callbacks, as well as the use of Ajax with SimpleModal.

    Demo Download

    OSX Style Dialog

    A modal dialog configured to behave like an OSX dialog. Demonstrates the use of the onOpen and onClose callbacks as well as a handful of options, and custom styling.

    Inspired by ModalBox, an OSX style dialog build with prototype.

    Demo Download

    OSX Style Modal Dialog

    Hello!

    SimpleModal gives you the flexibility to build whatever you can envision, while shielding you from related cross-browser issues inherent with UI development.

    As you can see by this example, SimpleModal can be easily configured to behave like an OSX dialog. With a handful options, 2 custom callbacks and some styling, you have a visually appealing dialog that is ready to use!

    (or press ESC or click the overlay)

    Confirm Override

    A modal dialog override of the JavaScript confirm function. Demonstrates the use of onShow as well as how to display a modal dialog confirmation instead of the default JavaScript confirm dialog.

    Demo Download

    2110/092

    WordPress-Tipz Theme Released

    Learned from http://designdisease.com/blog/tipz-theme-released/?utm_source=rss&utm_medium=rss&utm_campaign=tipz-theme-released
    designdisease.com又发布了一款Theme,这款主题颜色比较热情,挺好的,下边是Demo和下载地址。

    We wanted a good strong theme that could fit a wide variety of topics for Tipz, which mainly writes how-to articles among various other topics. The front page has an easy to use “feature” section so you can easily put on display your most in-depth posts. You can even slot in a nice picture and a post excerpt to accompany the headline by editing the feature-image custom field and setting the category to “Featured”. We always like our rounded corners, which give the theme a simple Web 2.0 feel.

    tipztheme

    The theme is fully widgetized. A special feature of this theme as we use in many of our themes is the logo changer. You can use the default WordPress setting (“blog name”) or you can use your own logo. Upload your logo in the root folder of Tipz theme and name it logo.png or you can use the logo.psd as a template. You will find the source in the root folder of the Tipz theme..

    This work is licensed Creative Commons Attribution-Share Alike 3.0 License. This means you may use it, and make any changes you like. Just leave the credits on footer if you respect the designer’s work.

    Enjoy !

    2010/090

    Icons-地图程序标记素材分享

    具体下载地址如下:http://code.google.com/p/google-maps-icons/
    这看名字哪,是给Google Map用的标记,下边是几个示例:

    Administration, Office & Industry

    All the icons in this Icon Category described and tagged.

    Culture & Entertainment

    All the icons described and tagged.

    Education & Kids

    All the icons described and tagged.

    Events & Weather

    All the icons described and tagged.

    Tagged as: No Comments
    1910/090

    AS3-对象的深度复制

    内容转载自:http://blog.youmila.com/?p=241
    AS3中通过ByteArray可以进行对象的深度拷贝:

    import flash.utils.ByteArray;
    import flash.utils.getQualifiedClassName;
    import flash.net.*;
    import src.*;
    function cloneObject(source:Object) :* {
    var typeName:String = getQualifiedClassName(source);//获取全名
    trace(”输出类的结构”+typeName);
    //return;
    var packageName:String = typeName.split(”::”)[0];//切出包名
    trace(”类的名称”+packageName);
    var type:Class = getDefinitionByName(typeName) as Class;//获取Class
    trace(type);
    registerClassAlias(packageName, type);//注册Class
    //复制对象
    var copier:ByteArray = new ByteArray();
    copier.writeObject(source);
    copier.position = 0;
    return copier.readObject();
    }
    

    有的人说用复制对象那一段不就可以了吗,但是实际上行不通。对于数组深度复制来说, 复制对象的后面4句代码就足够了。

    var a1:Array=[1,2,3];
    var a2:Array =cloneObject(a1);
    var a3:Array = a1;
    a1.push(”youmila”);
    trace(”a1:”+a1+”a2:”+a2+”a3″+a3);
    
    1610/090

    Grails Flex Integration

    Learnef from http://sebastien-arbogast.com/2009/10/24/grails-flex-integration-version-1-0/.
    Ever since I discovered Grails, I’ve never stopped looking for the best way to make it work with Flex (I guess for me, the search was NOT over). Why so? Simply because the less time we spend connecting components, mapping objects with the database and dealing with boilerplate code, the more time we have for building gorgeous user interfaces. As for usual web suspects like JSF, GWT, GSP and other HTML/JS-generators, they have never been the best solution for me.

    So how do we get Grails and Flex to work together? Well, Grails uses Spring behind the scenes and it is maintained by SpringSource, who also happen to be behind Spring BlazeDS integration in partnership with Adobe. So everything seems to be there… but there’s a problem. The best way to integrate any technology with Grails is via a plugin. Unfortunately the Grails Flex plugin is very old (it does not use Spring BlazeDS integration, but an old custom workaround) and only experimental. There is also a GraniteDS plugin for Grails, but GraniteDS is an alternative to BlazeDS, so it’s not the mainstream way of doing things. And Graeme Rocher has started working on a Spring BlazeDS integration plugin based on the old Flex plugin, but it was never released. Hmmm…

    I know, when you’re unhappy with an open source project, when you feel it’s missing something, the better way to help is to do it yourself and share it with the community. But the problem is, although I love using Grails, I’ve never developed a plugin for it before. And this Flex plugin doesn’t seem like an easy one to start with. That’s why I decided to do things differently.

    A few months ago, I published an article about Spring, Hibernate, BlazeDS and Flex. This article was very popular, both on my blog and on Adobe Developer Network. But new versions of Maven, Flex and Flexmojos have been released since then, so the article is a little bit outdated now. So why not use this opportunity to do an update?

    So here we go. In the following file, there is the full todolist-grails project, that you can also find on GitHub (this is my first Git project by the way). This first version is merely a proof-of-concept. It’s not a plugin, it’s a traditional Grails application with Flex infrastructure added to it.  And because I didn’t find a way to integrate Flex compiler with Grails yet, I’m still using IntelliJ Idea to build the Flex part. Still, I’m publishing it as it is because I hope people will help me improve it incrementally.

    So if you can help me improve this project and create a Grails plugin out of it in order to automate Flex compilation, integrate Spring Security, generate DTO’s automatically, you’re more than welcome. Let’s get this thing rolling.

    Tagged as: , No Comments
    1510/090

    CU3ER-Flash 3D image slider

    CU3ER是什么呢?CU3ER是一个方块形式的图片切换过渡效果。
    官方说明如下:

    What is CU3ER?

    CU3ER – flash 3D image slider you will love! It is:

    • FREE
    • EASY to set up
    • CUSTOMIZABLE via XML
    • TAILORED to provide a UNIQUE look & feel
    • INSPIRING
    • FUN-to-USE

    What can CU3ER be used for?

    CU3ER \kju:bər\, an image slider initially conceived to create 3D transitions between slides, turned out to be a convenient and multifunction solution that can be applied in a range of website building areas, from content slider to feature slider and image & banner rotator. Consider using it when you want to grab the user’s attention, and you’ll be delighted by the results!

    If you’d like to experience more creativity in web development, are striving to more visually appealing content, and prefer to have even more unique image transitions on your websites, try the CU3ER! Its magic is astonishing!

    Not always the best solution!

    To be fair, it must be admitted, the CU3ER is not always the best solution. In some cases, there are more appropriate answers to your needs. The user always comes first! Therefore, identify your target audience, analyze the content people are expecting to find, recognize the potential effects of the solution you’d like to implement! Once you’ve experienced the magic of CU3ER, you’ll hardly want to go back to anything known before!

    Requirements

    There are no special requirements for setting it up and running other than a limited knowledge of web authoring:

    • Flash Player 9+
    • XML Basics
    • Embedding .swf files into web pages (using SWFObject.js)
    • Experience in image editing (creating & exporting slides)

    License

    You can use CU3ER free of charge for your personal and/or commercial projects. CU3ER may not be redistributed or resold to other companies or third parties. Specifically, CU3ER may not be redistributed as part of a content management system or online hosting solution. Any credits or copyright notices must remain intact.

    Attribution

    Wondering how come CU3ER is so rad? Because it's:

    Tagged as: , No Comments
    1410/090

    JS Bin

    JS Bin是一个在线DebugJavascript和CSS的地方,大伙儿自己看吧奥~
    JS Bin is a webapp specifically designed to help JavaScript and CSS folk test snippets of code, within some context, and debug the code collaboratively.

    JS Bin allows you to edit and test JavaScript and HTML. Once you’re happy you can save, and send the URL to a peer for review or help. They can then make further changes saving anew if required.

    The original idea spawned from helping developers debugging an Ajax issue. The original aim was to build it using Google’s app engine, but in the end, it was John Resig’s Learning app that inspired Remy Sharp to build the whole solution in JavaScript with liberal dashes of jQuery and a tiny bit of LAMP for the saving process.

    javascript-online

    Tagged as: No Comments
    1310/090

    Flash vs Qt: The next battle?

    至于什么是Qt,参考这里:http://zh.wikipedia.org/wiki/Qt
    Both Qt and Flash platform have something in common: a cross-platform runtime environment.
    IMHO, Qt could be a Flash killer in the near future.
    Adobe introduced Adobe AIR on March, 2007, to provide a cross-platform runtime environment for building rich Internet applications using Adobe Flash, Adobe Flex, HTML, or Ajax, that can be deployed as a desktop application and maybe mobile.
    While Adobe AIR developers can benefit of using Adobe Flash, Adobe Flex, HTML, or Ajax skills to build applications that deploy to the desktop, Qt developers benefits from a successful open source framework, with high performance on embedded, mobile and desktop.
    There are some rumors of Adobe Air to mobile phones that could bring ActionScript 3.0, the current robust OOP programming language of Flash to mobile phones but the question is: Will Adobe be able to deliver AIR runtime to mobile phones with the same performance achieved by the trolls?
    …and…
    Will trolls be able to maintain Qt flexible and scalable with so many deliveries (Maemo, Symbian, Windows, …)?
    It’s my point of view, please, comment if you have any ideas or feedback about this.

    Tagged as: , No Comments
    1210/092

    Doit.im-任务管理工具

    官方网站:http://doit.im/
    我是被清爽的UI吸引的,主要呢,还有个AIR版的客户端,相对Google Calendar来说多了个功能。
    虽然目前才3825个人注册,不过在支持手机的版本出来之后会多起来的嘛~
    有个问题就是,没有对外的API,这样相比Google Calendar就逊色不少咯。
    下边是官方介绍:
    Doit.im 采用优秀的任务管理理念,引导您将脑袋清空,使您免受头脑中各种漂浮想法的干扰,有条不紊地组织规划各项任务,以集中注意力完成重要事项,将工作节奏牢牢把握在手中,轻松应对各项庞大繁杂的工作,在感受无压工作乐趣的同时,畅享高效工作的成就感!

    Page 1 of 212