DFdou's Blog Life is short,Be yourself.

3011/090

iPhone-Adobe Flash和Microsoft SliverLight

先牢骚下,早上打电话给it部门说win7的系统不提供技术支持,所以我要向上内网,先得把系统换成xp,无语。。
还好开短会的时候同事说可以解决,弄了下,使用802.1X可以直接验证,唉。。
OK,下边说正题,微软推iPhone版SL是在开会时候鸽子给的信息,来源是cnbeta,我估计Adobe看到这个消息会泪流满面,跟苹果交涉了那么久,最后还是被苹果拒绝。
从短文内容来看,似乎微软只是做了视频流的转换,我估计SL的虚拟机是无法撞到iPhone里去的,除非,,,除非微软用iPhone的sdk做一个虚拟机,当然这个以微软和adobe的实力都没什么问题,最重要的问题是,这个需要苹果说"OK"。不然啥都没的谈~~
从苹果做事的一贯做法和APP STORE和Flash的巨大竞争来看,我猜是没戏~~
不然adobe官方也不会无奈的给出这么一张图:
adobe flash

2711/090

Flash-New knowledge exchange for Flex/Flash/AIR developers

今天电脑崩了,结果嘛,就没写日志,转个博文偷懒下。来自:http://www.insideria.com/2009/11/new-knowledge-exchange-for-fle.html

There are about 250K developers working with Flex and AIR. If you add an army of ActionScript developers, this number will grow substantially. Where do you go if you have a technical issue while developing RIA? As of today, there no one place to ask questions and get answers. A respected forum flexcoders uses the outdated and hard to follow Yahoo! groups. Some people try to find answers visiting blogs they trust. Some developers post their questions on Twitter.

About a year ago Joel Spolsky and Jeff Atwood released a well designed and easy to follow knowledge exchange stackoverflow.com, where people earn reputation by suggesting the right solutions to people's problems. Flex/Flash/Air developers started to post their questions there among the plethora of questions on other technologies and programming languages.

Joel and Jeff went one step further and are offering the engine (stackexchange) for creation of similar knowledge exchanges for discussion any kinds of subjects. Using this engine is not free, but our company, Farata Systems continues contributing to Flex community and will pick up the cost involved with running the knowledge dedicated to RIA technologies that produce applications to be deployed with Flash Player.

We are just starting and created a an exchange Built4Flash on stackexchange engine and would like to invite Flex, Flash, AIR, and Coldfusion developers to post questions there and provide answers to others. The URL of the Web site ishttp://built4flash.stackexchange.com.

Your questions and answers not only will help others in solving their issues, but you'll also have a chance to become visible and reputable person in this lively and Flashy community.

I really hope you'll support this initiative.

Tagged as: , , No Comments
2511/090

记得关注你的竞争对手

browser
换了工作之后对工作工具的接触多了起来,上一个工作办公室Mac和Windows是5,5开,但是浏览器大家几乎都是Firefox,虽然要做下IE6,7的兼容,但是基本上不用去管IE8,Safari,理由很简单,国内客户基本用不到。这也算是个节约成本的做法,不过现在想想其实IE8和Safari相对IE6来说对CSS支持算很规范了(顺便呼吁一下"请升级您的IE6,thx")。至于Chrome,刚出来时候没发现自带调式工具,就一直放着,而且,习惯了Firefox,插件数量多嘛。
现在工作的地方Mac,Ubuntu差不多是55开,只有为数不多的人装了Windows,恩,我就是为数不多的其中一个哈哈。浏览器方面,IE6,7,8,Firefox,Chrome分布的很不均衡,只有为数不多的那群人装的是IE…
接触了一段时间才发现,原来Firebug类似的功能IE8,Chrome都是自带的,于是"豆腐你out,很out。" 现在是同时对我的评价,555啊~
flash vs sliverlight
因为主要在做Flash的工作,所以平时一般只关注Flash方面的新闻,Sliverlight在我看来一直是鸡肋,出了之后一直没当回事儿,国内对SL支持最多的估计就是腾讯,QQ安装包里有捆绑SL虚拟机,不知道MS这个单子付了多少米哈。MS自然也不是省油的灯,于是SL之后,SL3,SL4来了,有一天,忽然就发现SL已经完全不是当年的SL了,呵呵,谁叫平时不够关注哪。
怎么说呢,平时还是多关注点东西吧,尤其是竞争对手的产品,不然没法体现自己的优势的。
这就好比你和某人同时在追一个MM,你首先必须得了解MM(或者说消费者?),接着还要了解那个该死的情敌,这样才能做到知己知彼,百战不殆。
----------------------------------------------------------------------------------------------
最近打算装个Ubuntu,手痒吧,看隔壁,前后都是Ubuntu。
另外,在同学的影响下看了下Java,才发现说原来AS是这么繁琐的语法,Java简洁很多啊。

1911/090

Flash-数组作为函数参数时传的是引用

老实说,一直没有发现数组作为实参传递时传的是数组本身的引用,也就是实际地址。如此一来在函数操作的过程中,会直接改变原数组的值,有些场合可能需要这么做,而有些时候可能就不需要。
撇开直接修改的部分不谈,如何避免修改到原数组的值呢?方法应该有很多,简单的做法就是clone一个数组,来点代码吧:

var ary_test:Array=[1,2,3,4,5];
function arrayChange(ary:Array){
	var ary_tmp:Array=arrayClone(ary);
	ary_tmp.push("end");
	trace(ary_tmp);
}
function arrayClone(ary:Array):Array{
	var ary_tmp:Array=[];
	ary_tmp=ary_tmp.concat(ary);
	return ary_tmp;
}
arrayChange(ary_test);
trace(ary_test);
/*output:
1,2,3,4,5,end
1,2,3,4,5*/

ary_test数组有[1,2,3,4,5]5个元素,如果直接arrayChange(ary_test)而不var ary_tmp:Array=arrayClone(ary)再对ary_tmp进行push操作,那ary_test的值会直接被修改,最后变成[1,2,3,4,5,end]。加上一个var ary_tmp:Array=arrayClone(ary)的操作,这样ary_tmp就是另一个Object了,和ary_test的内存地址不是一个位置,这样可以完整的保存一个原始数组。
PS:话说昨天在网上看到一个如何让字符串变成传引用的求助帖,我才发现原来数组是传的引用,唉,我太弱了……

Tagged as: , No Comments
411/090

Flash-Global Error Handling in AIR 2.0 and Flash 10.1

Global Error Handling全局变量处理,以下内容翻译自http://blogs.adobe.com/cantrell/archives/2009/10/global_error_handling_in_air_20.html,人肉翻译哈哈。
在MAX presentation中最受欢迎的一个内容是global error handling (GEH),GEH可以让你处理全部捕获的errors(包括同步error和异步error事件)。下边是GEH的一个工作示例:

< ?xml version="1.0" encoding="utf-8"?>
<mx :WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" applicationComplete="onApplicationComplete();">
    </mx><mx :Script>
        < ![CDATA[
            private function onApplicationComplete():void
            {
                loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtError);
            }

            private function onUncaughtError(e:UncaughtErrorEvent):void
            {
                // Do something with your error.
                trace(e.error, e.errorID);
            }

            private function onCauseError(e:MouseEvent):void
            {
                var foo:String = null;
                try
                {
                    trace(foo.length);
                }
                catch (e:TypeError)
                {
                    trace("This error is caught.");
                }

                // Since this error isn't caught, it will cause the global error handler to fire.
                trace(foo.length);
            }
        ]]>
    </mx>
    <mx :Button label="Cause TypeError" click="onCauseError(event);"/>

注册捕获errors是非常便利的,不过开发人员也不需要捕获所有的errors。举个例子,你还是需要在某些地方捕获IOError事件,以方便修复。不过在AIR 2.0 (和 FP 10.1)里,你可以注册GEH来更方便地捕获到这些error。
现在的一个大问题是,当你捕获到一个没有定位的error时你该怎么做?这要看是什么样的Application。它可能就像一个函数一路执行到底,也没有告诉你现在app的状态。最安全的做法大概是log error,显示一个醒目的对话框,然后退出app(当然,如果error可以被预测,并且易于恢复,你应该明确地捕获它)。
你可以尝试将error信息发送到你的服务器,包括通过电子邮件发送error log到技术支持的电子邮件地址。如果这是个单机版的软件,或许提供电话或者地址让用户来反馈也不错。
It's entirely up to you. We provide the API, you provide the solution.

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
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
810/090

Flash to iPhone

appsfor_iphone
Learned from http://labs.adobe.com/technologies/flashcs5/appsfor_iphone/
内容很简单,大致就是说Flash登录了iPhone。
Flash Professional CS5 will enable you to build applications for iPhone and iPod touch using ActionScript 3. These applications can be delivered to iPhone and iPod touch users through the Apple App Store.*
A public beta of Flash Professional CS5 with prerelease support for building applications for iPhone is planned for later this year. Sign up to be notified when the beta starts.


709/091

Flash-一些常用物理公式和AS3的结合应用

来自《Foundation Actionscript 3.0 Animation: Making Things Move!》的物理公式:
向鼠标(或者任何一个点)旋转:

// 用要旋转到的 x, y 坐标替换 mouseX, mouseY
dx = mouseX - sprite.x;
dy = mouseY - sprite.y;
sprite.rotation = Math.atan2(dy, dx) * 180 / Math.PI;

创建波形:

// 将 x, y 或其它属性赋值给 Sprite 影片或影片剪辑,
// 作为绘图坐标,等等。
public function onEnterFrame(event:Event){
value = center + Math.sin(angle) * range;
angle += speed;
}

创建圆形:

// 将 x, y 或其它属性赋值给 Sprite 影片或影片剪辑,
// 作为绘图坐标,等等。
public function onEnterFrame(event:Event){
xposition = centerX + Math.cos(angle) * radius;
yposition = centerY + Math.sin(angle) * radius;
angle += speed;
}
2807/092

Flash – 说是XXX的模糊理论视觉模型?

是这样的,在AS3天地会看到个帖子,说HTML5会不会是Flash终结者,在里边刚好看到一个模糊理论模型的东西,点进去看了下,是用JS实现的,,地址在这里了:Canvas Stuff
JS和Flash是非常的像,SO,拷贝一下~来来看看Demo:

Tagged as: , Continue reading
2707/090

Flash-Setter & Getter

在类里边,一些变量会需要get和set方法,而常用的解决方法有两种,一种是自己写get和set函数,另一种是用set和get方法,2个看起来差不多,例子如下:

package {
	public class Person{
		private var _name:String;
		private var _sex:String;
		function Person(name:String){
			this._name = name;
		}
		public function setSex(sex:String):void{
			this._sex = sex;
		}
		public function getSex():String{
			return _sex;
		}
	}
}

我们建立了一个Person类,对外提供了函数setSex()和getSex(),外部使用的时候调用这2个函数就可以了.如:'person.setSex("male")','person.getSex()'....
而使用set和get方法则是这样:

package {
	public class Person{
		private var _name:String;
		private var _sex:String;
		function Person(name:String){
			this._name = name;
		}
		public function set sex(sex:String):void{
			this._sex = sex;
		}
		public function get sex():String{
			return _sex;
		}
	}
}

这样一来的话就可以直接使用"person.sex"来set和get _sex的值了.
本来一直用的是第1个方案,后来发现第2个方法更简单直观,而且很多第3方类都这么写嘛~

Tagged as: , , , No Comments
2007/090

AS3-子弹躲避游戏(下)

接上一篇《AS3-子弹躲避游戏(上)》
有了Enemy和Role之后,自然就是游戏的主体控制部分了,这里是Game类:
这个类负责生成多少个Enemy,Role如何移动,游戏如何开始和如何结束,以及控制其他事务,比如记时类。

package{
	import flash.display.Sprite;
	import flash.events.*;
	import flash.utils.Timer;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import fl.controls.Button;
	import Config;
	import Role;
	import Enemy;
	import TimeCount;

	public class Game extends Sprite{
		private var _role:Role;
		private var _enemy:Sprite;
		private var _time:TimeCount;
		private var _enemyTotal:uint;
		private var _gameFlag:Boolean;

		private var startBtn:Button;
		private var gameInfo:TextField;

		//存储四个方向键是否按下的变量
		private var leftArrow:Boolean=false;
		private var rightArrow:Boolean=false;
		private var upArrow:Boolean=false;
		private var downArrow:Boolean=false;

		public function Game():void{
			startBtn = new Button();
			startBtn.label = "StartGame";
			startBtn.x=(Config.STAGE_W-startBtn.width)/2;
			startBtn.y=(Config.STAGE_H-startBtn.height)/2;
			addChild(startBtn);
			startBtn.addEventListener(MouseEvent.MOUSE_DOWN,gameStart);
			gameInfo = new TextField();
			gameInfo.autoSize = TextFieldAutoSize.LEFT;
			gameInfo.selectable = false;
			gameInfo.text = "上下左右方向键控制方块移动,被黑球击中就挂了。";
			gameInfo.x = (Config.STAGE_W-gameInfo.width)/2;
			gameInfo.y = startBtn.y-30;
			addChild(gameInfo);
		}
		private function gameStart(_evt:MouseEvent):void{
			startBtn.removeEventListener(MouseEvent.MOUSE_DOWN,gameStart);
			startBtn.visible = false;
			gameInfo.visible = false;
			init();
		}
		private function init():void{
			initTime();
			initRole();
			initEnemy();
		}
		private function initTime():void{
			_time = new TimeCount();
			addChild(_time);
		}
		private function initRole():void{
			_role = new Role();
			addChild(_role);
			_role.x=(Config.STAGE_W-_role.width)/2;
			_role.y=(Config.STAGE_H-_role.height)/2;
			stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressedDown);
			stage.addEventListener(KeyboardEvent.KEY_UP, keyPressedUp);
			_role.addEventListener(Event.ENTER_FRAME, roleMove);
			stage.addEventListener(Event.DEACTIVATE, missingStage);//Flash处于非活动状态时调用
		}

		private function initEnemy():void{
			_enemyTotal = Config.ENEMY_TOTAL;
			var t:Timer=new Timer(2000,1);
			t.addEventListener(TimerEvent.TIMER, timeToCreateEnemy);
            t.start();
		}

		private function createEnemy():void{
			var enemy=new Enemy();
			enemy.setRole(_role);
			_enemy.addChild(enemy);
		}
		private function getEnemyNum():uint{
			return this.numChildren;
		}

		private function timeToCreateEnemy(_evt:TimerEvent):void{
			_enemy = new Sprite();
			addChild(_enemy);
			for (var i:uint=0; i<_enemytotal ; i++) {
				createEnemy();
			}
			addEventListener(Event.ENTER_FRAME,checkFlag);
		}

		//按键时的检测,左上右下分别是37,38,39,40
		private function keyPressedDown(_evt:KeyboardEvent) {
			if (_evt.keyCode==37) {
				leftArrow=true;
			} else if (_evt.keyCode == 39) {
				rightArrow=true;
			} else if (_evt.keyCode == 38) {
				upArrow=true;
			} else if (_evt.keyCode == 40) {
				downArrow=true;
			}
		}

		//松开按键时
		private function keyPressedUp(_evt:KeyboardEvent) {
			if (_evt.keyCode==37) {
				leftArrow=false;
			} else if (_evt.keyCode == 39) {
				rightArrow=false;
			} else if (_evt.keyCode == 38) {
				upArrow=false;
			} else if (_evt.keyCode == 40) {
				downArrow=false;
			}
		}
		private function roleMove(_evt:Event) {
			//移动的速度
			var speed:Number=Config.ROLE_SPEED;
			if (leftArrow) {
				//MC的位置检测,下边相同
				if (0<=_role.x) {
					_role.x-=speed;
				}
			}
			if (rightArrow) {
				if (_role.x<=Config.STAGE_W-_role.width) {
					_role.x+=speed;
				}
			}
			if (upArrow) {
				if (0<=_role.y) {
					_role.y-=speed;
				}
			}
			if (downArrow) {
				if (_role.y<=Config.STAGE_H-_role.height*2) {
					_role.y+=speed;
				}
			}
		}

		//Flash处于非激活状态时
		private function missingStage(_evt:Event) {
			leftArrow=false;
			rightArrow=false;
			upArrow=false;
			downArrow=false;
		}
		private function checkFlag(_evt:Event):void{
			//trace(_gameFlag);
			if(_gameFlag){
				_gameFlag = false;
				gameOver();
			}
		}
		private function gameOver(){

			removeEventListener(Event.ENTER_FRAME,checkFlag);
			_time.stopTime();

			gameInfo.text = "You Failed At " + _time.getTime() + " Second!";
			var format:TextFormat = new TextFormat();
			format.font = "Arial";
            format.color = 0xFF0000;
            format.size = 30;
            gameInfo.setTextFormat(format);
			gameInfo.x=(Config.STAGE_W-gameInfo.textWidth)/2;
			gameInfo.y=(Config.STAGE_H-gameInfo.textHeight)/2;
			gameInfo.visible = true;

			startBtn.visible = true;
			startBtn.y = gameInfo.y + 40;
			startBtn.addEventListener(MouseEvent.MOUSE_DOWN,gameStart);

			//_role.roleClear();
			_role.removeEventListener(Event.ENTER_FRAME, roleMove);
			removeChild(_role);

			while(_enemy.numChildren>0){
				Enemy(_enemy.getChildAt(0)).enemyClear();
				_enemy.removeChildAt(0);
			}
			removeChild(_enemy);
		}
		public function setGameFlag(_value:Boolean):void{
			_gameFlag = _value;
		}
	}
}

1707/090

AS3-子弹躲避游戏(上)

先来Demo:

1607/090

AS2-System.capabilities

先来个Demo看下System.capabilities到底是干嘛用的:

1307/090

AS3 Code Optimization一些代码优化的问题

Learned from http://www.insideria.com/2009/04/51-actionscript-30-and-flex-op.html
1.首先是Array:
建议使用var a = []; 而不是var a = new Array();
2.最快的数组复制方式:
var copy : Array = sourceArray.concat();
记得曾经有人做过测试,的确是concat速度最快。
3.数组的赋值速度不如从别的数组获得值:
employees.push(employee);
employees[2] = employee;
速度不如var employee : Employee = employees[2];
4.使用const 来定义常量
public const APPLICATION_PUBLISHER : String = "Company, Inc.";
5.如果一个类不会再被继承,要使用final前缀:
public final class StringUtils

Tagged as: , Continue reading
Page 1 of 812345...Last »