A locale is the combination of a language and a country code.
一個在地化表示,是由一個語言與國家所組成。
example, en_US refers to the English language as spoken in the United States.
例如en_US 就是 英語做為口頭語在美國。
簡單說就是 locale = 語言 + 國碼
一個環境區域中所用的貨幣、日期格式也都可能會有所不同。
在區域化的素材使用上,還可以包含音頻、圖像、視訊,讓應用程序能夠針對不同文化區域來給予不同素材來呈現使用。
有關Flex中使用在地化功能,請參考Flex4官方Help。
2011年1月11日 星期二
2011年1月6日 星期四
Flex 程式效能簡易測試工具
最近離職後開始在整理自已做測試的小東西,因此順便把測試結果簡單重整成一個工具類,以下是一個簡單的程式執行效能測試類,不夠好或考量不夠的地方請大家多多指教~
//interface
package com.utils
{
public interface ILoopTestTools
{
function startExecuteTestFunction():void
function set testFunctionA(functin:Function):void;
function set testFunctionB(functin:Function):void;
}
}
//Class
package com.utils
{
import flash.display.DisplayObject;
import flash.events.IEventDispatcher;
import flash.events.MouseEvent;
import flash.utils.Timer;
import flash.utils.getTimer;
import mx.controls.TextArea;
import mx.core.IButton;
import mx.managers.IBrowserManager;
//interface
package com.utils
{
public interface ILoopTestTools
{
function startExecuteTestFunction():void
function set testFunctionA(functin:Function):void;
function set testFunctionB(functin:Function):void;
}
}
//Class
package com.utils
{
import flash.display.DisplayObject;
import flash.events.IEventDispatcher;
import flash.events.MouseEvent;
import flash.utils.Timer;
import flash.utils.getTimer;
import mx.controls.TextArea;
import mx.core.IButton;
import mx.managers.IBrowserManager;
2011年1月5日 星期三
FlexDeep Link,Flex BrowserManager與IBrowserManager 測試
Flex有兩個可以管理「瀏覽器歷程的」的原生類,一個是BrowserManager一個是HistoryManager,搜尋過網路上資訊得知,現在大多以BowserManager為主HistoryManager已經少用,但是為什麼、是否需視不同狀況而用,目前本編不下結果,原因是還未做過HistoryManager的測試,待測試過後再來做個比較文章,因此本編著重於BrowserManager與IBrowserManager的應用測試。
/****
* 注意:測試時發現,使用SDK3.5運作不正常,用SDK 4,深層管理運作正常,問題還未查明。
* 參考文件 Adobe官方文件:
* http://help.adobe.com/zh_CN/AS3LCR/Flex_4.0/mx/managers/IBrowserManager.html
* http://help.adobe.com/zh_CN/AS3LCR/Flex_4.0/mx/managers/BrowserManager.html
*
* 主要用法:BrowserManager類只用來拿到實體,
*主要操作是藉由IBrowserManager介面來實現操作。
* */
//測試程式
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
historyManagementEnabled="false"
creationComplete="startProcess()"
>
<!--
BrowserManagerManager與historyManager同時間只能用一個,
因此使用BrowserManager做深層管理時要將historyManagementEnabled設為flase
-->
<mx:Script>
<![CDATA[
import mx.events.BrowserChangeEvent;
import mx.managers.BrowserManager;
import mx.managers.IBrowserManager;
import mx.utils.ObjectUtil;
import mx.utils.URLUtil;
private var _IbrowserManager:IBrowserManager;
private function startProcess():void
{
/*Step1.
取得BrowserManager實體,BowserManager是一個獨體模式,
因此使用getInstance取回運行環境中唯一的實體物件。
*/
_IbrowserManager = BrowserManager.getInstance();
//Step2. 初始化BrowserManager
_IbrowserManager.init();
//將Browser的各項屬性,呈現於From表單結構上
updateValue();
//對BrowserManager加上真聽式
addListener();
}
/****
* 注意:測試時發現,使用SDK3.5運作不正常,用SDK 4,深層管理運作正常,問題還未查明。
* 參考文件 Adobe官方文件:
* http://help.adobe.com/zh_CN/AS3LCR/Flex_4.0/mx/managers/IBrowserManager.html
* http://help.adobe.com/zh_CN/AS3LCR/Flex_4.0/mx/managers/BrowserManager.html
*
* 主要用法:BrowserManager類只用來拿到實體,
*主要操作是藉由IBrowserManager介面來實現操作。
* */
//測試程式
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
historyManagementEnabled="false"
creationComplete="startProcess()"
>
<!--
BrowserManagerManager與historyManager同時間只能用一個,
因此使用BrowserManager做深層管理時要將historyManagementEnabled設為flase
-->
<mx:Script>
<![CDATA[
import mx.events.BrowserChangeEvent;
import mx.managers.BrowserManager;
import mx.managers.IBrowserManager;
import mx.utils.ObjectUtil;
import mx.utils.URLUtil;
private var _IbrowserManager:IBrowserManager;
private function startProcess():void
{
/*Step1.
取得BrowserManager實體,BowserManager是一個獨體模式,
因此使用getInstance取回運行環境中唯一的實體物件。
*/
_IbrowserManager = BrowserManager.getInstance();
//Step2. 初始化BrowserManager
_IbrowserManager.init();
//將Browser的各項屬性,呈現於From表單結構上
updateValue();
//對BrowserManager加上真聽式
addListener();
}
2010年12月31日 星期五
將displayObject轉成bitmap與bitmapData的工具類
之前寫了一篇displayObject轉成bitmap的文章,最近在整理電腦時,將以前做過的測試整理,因此將其轉成工具類別便於日後使用,程式碼如下:
package com.tools.graphics
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.DisplayObject;
import flash.display.Loader;
import flash.display.LoaderInfo;
public class LoaderToBitmap
{
/**
*建構式參數使用一個內隱類,避免使用者建立實體,
*因為as3不能使用private給予建構式的關係,
*但是使用者若給予null之後依然會被執行super()的建構式,所以無法避免得很完全。
*/
public function LoaderToBitmap(dontCreate:DontCreate)
{
}
static public function cloneBitmap(display:DisplayObject):Bitmap
{
var bitmap:Bitmap = new Bitmap(cloneBitmapData(display));
return bitmap;
}
static public function cloneBitmapData(display:DisplayObject):BitmapData
{
var bitMapData:BitmapData = new BitmapData(display.width , display.height);
bitMapData.draw(display);
return bitMapData;
}
}
}
class DontCreate
{
public function DontCreate()
{
}
}
//在Flex4 SDK環境下,使用範例
package com.tools.graphics
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.DisplayObject;
import flash.display.Loader;
import flash.display.LoaderInfo;
public class LoaderToBitmap
{
/**
*建構式參數使用一個內隱類,避免使用者建立實體,
*因為as3不能使用private給予建構式的關係,
*但是使用者若給予null之後依然會被執行super()的建構式,所以無法避免得很完全。
*/
public function LoaderToBitmap(dontCreate:DontCreate)
{
}
static public function cloneBitmap(display:DisplayObject):Bitmap
{
var bitmap:Bitmap = new Bitmap(cloneBitmapData(display));
return bitmap;
}
static public function cloneBitmapData(display:DisplayObject):BitmapData
{
var bitMapData:BitmapData = new BitmapData(display.width , display.height);
bitMapData.draw(display);
return bitMapData;
}
}
}
class DontCreate
{
public function DontCreate()
{
}
}
//在Flex4 SDK環境下,使用範例
2010年10月8日 星期五
個人學習MongoDB後,對於document的認知
- A document is the basic unit of data for MongoDB, roughly equivalent to a row in a relational database management system (but much more expressive).
- Similarly, a collection can be thought of as the schema-free equivalent of a table.
- A single instance of MongoDB can host multiple independent databases, each of which can have its own collections and permissions.
- MongoDB comes with a simple but powerful JavaScript shell, which is useful for the administration of MongoDB instances and data manipulation.
- Every document has a special key, "_id", that is unique across the document’s collection.
collection很好理解但document就字面上有點難理解,但看完Java Driver運作方式後,對document我的認知如下:
MongoDB的document長像是JSON的格式,document在RDBMS上如同是一個row。
{
"name" : "MongoDB",
"type" : "database",
"count" : 1,
"info" : { x : 203, y : 102 }
}
在mongoDB java Driver使用上要寫入如上JSON格式資料的語法如下:
//建立最外層key:value,此時還不是完整的parent document
BasicDBObject doc = new BasicDBObject();
doc.put("name", "MongoDB");
doc.put("type", "database"); doc.put("count", 1);
//建立info的sub document
BasicDBObject info = new BasicDBObject();
info.put("x", 203);
info.put("y", 102);
//將sub document寫入doc使其成為完整的parent document.
doc.put("info", info);
//將這個完整的parent document插入到collection,這個collection類似RDBMS的table.
coll.insert(doc);
由程式邏輯來理解
我認為由最外層來看這個結構是一個parent document
{
"name" : "MongoDB",
"type" : "database",
"count" : 1,
"info" : { x : 203, y : 102 }
}
//而info的value也是一個document,就是parent document裡再包含了一個sub document.
{ x : 203, y : 102 }
因此整個JSON格式就可以看成是RDBMS裡的一個row,對於想從mongoDB拿資料的程式來說這一個最外層就是一個document,而對於mongoDB自己內部來說內層那個info也是一個document。
從程式邏輯來看能理解MongoDB的資料結構了,但我無法很明白的來敘述這種關係,並且理解也可能有誤解,不過當由程式直接操作來看,document到底是什麼就變得不是那麼重要,有點張無忌學太極拳、劍,最後無招勝有招。
{
"name" : "MongoDB",
"type" : "database",
"count" : 1,
"info" : { x : 203, y : 102 }
}
在mongoDB java Driver使用上要寫入如上JSON格式資料的語法如下:
//建立最外層key:value,此時還不是完整的parent document
BasicDBObject doc = new BasicDBObject();
doc.put("name", "MongoDB");
doc.put("type", "database"); doc.put("count", 1);
//建立info的sub document
BasicDBObject info = new BasicDBObject();
info.put("x", 203);
info.put("y", 102);
//將sub document寫入doc使其成為完整的parent document.
doc.put("info", info);
//將這個完整的parent document插入到collection,這個collection類似RDBMS的table.
coll.insert(doc);
由程式邏輯來理解
我認為由最外層來看這個結構是一個parent document
{
"name" : "MongoDB",
"type" : "database",
"count" : 1,
"info" : { x : 203, y : 102 }
}
//而info的value也是一個document,就是parent document裡再包含了一個sub document.
{ x : 203, y : 102 }
因此整個JSON格式就可以看成是RDBMS裡的一個row,對於想從mongoDB拿資料的程式來說這一個最外層就是一個document,而對於mongoDB自己內部來說內層那個info也是一個document。
從程式邏輯來看能理解MongoDB的資料結構了,但我無法很明白的來敘述這種關係,並且理解也可能有誤解,不過當由程式直接操作來看,document到底是什麼就變得不是那麼重要,有點張無忌學太極拳、劍,最後無招勝有招。
2010年10月7日 星期四
MnogoDB JAVA Driver配置
MongoDB Driver官方頁面
Java Driver下載頁面
本文撰寫時Java Driver最新版本為 Version2.1
Step1.下載MongoDB JAVA Driver
@ubuntu:~/Downloads$ wget http://github.com/downloads/mongodb/mongo-java-driver/mongo-2.1.jar
Java Driver下載頁面
本文撰寫時Java Driver最新版本為 Version2.1
Step1.下載MongoDB JAVA Driver
@ubuntu:~/Downloads$ wget http://github.com/downloads/mongodb/mongo-java-driver/mongo-2.1.jar
Step2.建立目錄mongoDriver
於/opt底下建立一個目錄以放置mongo-2.1.jar
@ubuntu:/opt$ sudo mkdir mongoDriver
Step3.將mongo-2.1.jar移至/opt/mongoDriver底下
@ubuntu:~/Downloads$ sudo mv mongo-2.1.jar /opt/mongoDriver/
Step4.開啟Eclipse,開啟一個Java Project
Step5.Libraries中Add External JARs將mongo-2.1.jar加入
//待續
於/opt底下建立一個目錄以放置mongo-2.1.jar
@ubuntu:/opt$ sudo mkdir mongoDriver
Step3.將mongo-2.1.jar移至/opt/mongoDriver底下
@ubuntu:~/Downloads$ sudo mv mongo-2.1.jar /opt/mongoDriver/
Step4.開啟Eclipse,開啟一個Java Project
Step5.Libraries中Add External JARs將mongo-2.1.jar加入
//待續
Linux上配置Eclipse
Eclipse官方網址http://www.eclipse.org/
本篇將會下載 Eclipse IDE for Java EE Developers Linux 64bit
Step1.下載Eclipse for JavaEE Linux64版本
Step2.解開壓縮
@ubuntu:~/Downloads$ tar xzf eclipse-jee-helios-SR1-linux-gtk-x86_64.tar.gz
Step3.將解開資料夾移到/opt底下
@ubuntu:~/Downloads$ sudo mv eclipse /opt/
Step4.執行eclipse
:~/Downloads$ ./|/opt/eclipse/eclipse
本篇將會下載 Eclipse IDE for Java EE Developers Linux 64bit
Step1.下載Eclipse for JavaEE Linux64版本
Step2.解開壓縮
@ubuntu:~/Downloads$ tar xzf eclipse-jee-helios-SR1-linux-gtk-x86_64.tar.gz
Step3.將解開資料夾移到/opt底下
@ubuntu:~/Downloads$ sudo mv eclipse /opt/
Step4.執行eclipse
:~/Downloads$ ./|/opt/eclipse/eclipse
本篇是強迫自己使用Shell命令操作,但在ubuntu下具有桌面環境,可以如下
Step1.直接用fireFox下載,下載完檔案預設上會存放在home下的Downloads目錄裡。
Step2.打開Downloads目錄點擊下載之檔案即可解壓。
Step3.將解壓後之目錄移至/opt底下。
Step4.在eclipse目錄底下有個eclipse執行檔,直接點擊即可開啟eclipse。
Step5.替eclipse建立捷徑在ubuntu桌面上。
訂閱:
文章 (Atom)