Tuesday, August 19, 2008

flex 3 裡有趣的資料轉型規則

http://livedocs.adobe.com/flex/3/html/help.html?content=03_Language_and_Syntax_12.html

Type conversions

有興趣的自己看,為什麼說有趣呢...主要是int與boolean部份

全都記起來後,寫程式會更加簡潔快速


1. boolean 轉 int

var myBoolean:Boolean = true;
var myUINT:uint = uint(myBoolean);
var myINT:int = int(myBoolean);
var myNum:Number = Number(myBoolean);
trace(myUINT, myINT, myNum); // 1 1 1
myBoolean = false;
myUINT = uint(myBoolean);
myINT = int(myBoolean);
myNum = Number(myBoolean);
trace(myUINT, myINT, myNum); // 0 0 0

非常有趣,也非常貼心的轉法,迎合false為0,true為1的預期心裡


2.The output from the example shows that, of the three numbers, only 0 returns a value of false:

Boolean(-1) is true
Boolean(0) is false
Boolean(1) is true

不同的是,這裡只有0才回傳false,負數一樣回傳1喔

3.Casting to Boolean from a String value returns false if the string is either null or an empty string (""). Otherwise, it returns true.

var str1:String; // Uninitialized string is null.
trace(Boolean(str1));// false

var str2:String = "";// empty string
trace(Boolean(str2));// false

var str3:String = " "; // white space only
trace(Boolean(str3));// true

有趣吧,Boolean類別會自動幫你判斷,如果是空字串或是null,自動傳回0,有值或是空白字元都是傳回1,如果空白字元也想傳回0,就要善用 Trim 方法了


廢話這麼多之後,為什麼說寫程式會更加簡潔呢?

//obj.val可能是我們從server端吃下來的資料,有時是空值null有時是空字串""
//用 if(obj.val.toString()=="" || obj.val.toString()==null) 這種寫法就落伍摟
//請看這句
if(Boolean(String(obj.var1)))
trace("there's something")
else
trace("there's nothing")

//接下來,引入在C#中特殊的if else寫法進來
trace(Boolean(obj.var1)?"there's something":"there's nothing";

還可以這樣用喔
var description:String = Boolean(obj.var1)?String(obj.var1):"please enter description"
也就是當obj.var1有值時,就塞給 description
為null時,就塞"please enter description" 這段文字給 description

就醬

Wednesday, August 13, 2008

Google APIs 實現 Google Suggestion 功能

http://ysl-paradise.blogspot.com/2008/07/android-google-apis-google-suggestion.html
(sample是用android手機就是了)
弄ria 有機會會用到 之後一些攔位可能user需要auto fill

DataGrid设置背景色

http://bufanliu.javaeye.com/blog/197513

Monday, August 11, 2008

BitmapText 程式(旋轉字for 9.0)

http://ticore.blogspot.com/2008/07/as3-bitmaptext.html
研究研究Ticore's Blog 寫的
直的tab bar應該可以用

Friday, August 8, 2008

flex mockup

以後就老闆先用這先畫好ui
我們再作
http://www.balsamiq.com/products/mockups#

Monday, August 4, 2008

Sony也來玩虛擬社群了!!!

當我們準備要為三爽oem時...
索尼也進入虛擬社群的世界
是我們資訊落後沒看到而已嗎? 一直覺得日本3D很強但怎麼都沒走上網路...
很像線上版的模擬市民也像second life
好像要用ps3玩就是了...(不過有預感也會走入電腦端...)

http://www.jp.playstation.com/ps3/home/
http://gnn.gamer.com.tw/0/29680.html
http://game.sina.com.hk/cgi-bin/nw.cgi?action=view&d=2007-03-08&id=8598