2010年11月10日 星期三

Simple Canvas Demo

Below is js code:

$(function(){
var selectColor = 'red';
var canvas = document.getElementById('canvas')
var ctx = canvas.getContext('2d');
$('#canvas').mousedown(function(e){


ctx.strokeStyle = selectColor;
ctx.beginPath();
ctx.moveTo(e.clientX, e.clientY);
ctx.lineTo(e.clientX-1, e.clientY-1);
var px,py;
$('#canvas').bind('mousemove',function(e){

var x = px = e.clientX;
var y = py = e.clientY;

ctx.lineTo(x, y);
ctx.lineTo(x+2, y+2);
ctx.stroke();

$('#canvas').mouseup(function(e){
$('#canvas').unbind('mousemove');
ctx.lineTo(e.clientX, e.clientY);
ctx.lineTo(e.clientX+2, e.clientY+2);
});
});
})

$(document).mouseup(function(){
$('#canvas').unbind('mousemove');
});

var colors = ['#0000FF','#FFFF00','#00FF00','#FF0000','#FF91FE','#BE6100','#BCBE00','#5DBE00','#00BCBE'];
for(var i=0;i<10;i++){ class="tool" id="+i+">');
$('#'+i).css({'background-color':colors[i%colors.length]});
$('#'+i).click(function(){
$(this).addClass('toolactive');
selectColor = $(this).css('background-color');
}).mouseup(function(){
$(this).removeClass('toolactive');
});
}

$('#canvas').mouseover(function(e){
//tools.detect(e);
}).mousemove(function(e){
tools.detect(e);
}).mouseout(function(e){
$('#tools').mousemove(function(){
$('#tools').css({opacity:1});
}).mouseout(function(){
tools.hide();
});
tools.hide();
});
});




var tools ={
detect:function(e){
if(e.pageY>400){
this.show();
}else{
this.hide();
}
},
show:function(){
$('#tools').stop().animate({opacity:1},'slow',function(){
});
},
hide:function(){
$('#tools').stop().animate({opacity:0},'slow',function(){
});
}
}

Below is css code:

#canvas{
border:solid;
z-index:100;
}

.tool{
float:left;
padding:5px;
margin:5px;
width:50px;
height:30px;
background-color:#0000FF;
}

.toolactive{
background-color:#FF0000;
}

#tools{
background-color:#DDDDDD;
position:absolute;
bottom:25%;
left:15%;
float:left;
width:360px;
height:100px;
border:solid;
opacity:0;
}

Below is html code:






























Your browser should support canvas tag.
Demo link

2010年9月29日 星期三

Realize offline database store image file

  1. We could use convas.toDataURL() function to get base64 character,and store those data into sqllite data base
  2. Retrieve the hexadecimal data and pass those on the img tag i.e
  3. convas.toDataURL() will get as below data:


Reference as below:
1. https://developer.mozilla.org/en/Canvas_tutorial/Drawing_shapes
2. http://en.wikipedia.org/wiki/Data_URI_scheme

2010年8月26日 星期四

Location of flashlog.txt

The output of trace statements is logged to flashlog.txt in the debug version of Flash
Following is the location of flash player log file (flashlog.txt) on various operating systems.

  • Windows Vista : C:\Users\{user-name}\AppData\Roaming\Macromedia\Flash Player\Logs
  • Windows XP : C:\Documents and Settings\{user-name}\Application Data\Macromedia\Flash Player\Logs
  • Linux : /home/{user-name}/.macromedia/Flash_Player/Logs/
  • Mac : /Users/{user-name}/Library/Preferences/Macromedia/Flash Player/Logs/

2010年8月10日 星期二

How to use Chrome console


if(!window.console)
console = {};
console.log = console.log || function(){};
console.warn = console.warn || function(){};
console.error = console.error || function(){};
console.info = console.info || function(){};

console.log('--log--');
console.error('--error--');
console.info('--info--');
console.warn('--warn--');

2010年6月30日 星期三

flashplayer debug mode on firefox got crash error (Firefox上flashplayer 一直當機)

最近使用Firefox在寫Flex在debug mode,正在專注要看varible的變化
結果就flash就當機了
google了一下 找到T客邦的這篇文章

外掛當機,本尊沒事的Firefox 3.6.4來了
總結了一下
我做的小修改
主要就是在 firefox 叫出 about:config 後 篩選條件 dom.ipc.plugins.enabled
其中 dom.ipc.plugins.enabled.npswf32.dll; 應該是關連 flashplayer的把它關掉就不會再當機啦
T客邦中另外提到可以下 about:crashes 看一下當機紀錄,還看不是很懂
再者就是 http://www.mozilla.com/en-US/plugincheck/ 可以 check一下firefox裝了哪些plugin

2011/05/06 updated

In 4.0.1 version cant’ got above option
need to search below attribute
dom.ipc.plugins.timeoutSecs
and set the value to –1
 
2011/07/20 updated
In 5.0 version occur this error
發現容易停止回應的程式碼(Script)  [In engilish is unresponsive script warning]
need to setup another attribute
dom.max_script_run_time
and set the value to 20
if can’t find out this attribute ,create new attribute as above

reference link:

http://kb.mozillazine.org/Unresponsive_Script_Warning   <= offcial(english)

http://tw.knowledge.yahoo.com/question/question?qid=1608040905384 <= yahoo+(chinese)

 



2010年6月9日 星期三

Flex Load Image with ProgressBar







import mx.collections.ArrayCollection;
[Bindable]
private var datas:ArrayCollection= new ArrayCollection([{label:'Flex',data:'http://mixmatters.com/hot/2008/images/DJ_Flex-Te_Quiero.jpg'},
{label:'Apple',data:'http://www.teksource.com.tw/Quotation_TEK/images/product/APPLE.jpg'},
{label:'Google',data:'http://140.136.240.106/98/images/google_logo.jpg'},
{label:'Nokia',data:'http://www.blogcdn.com/www.engadgetmobile.com/media/2008/11/nokia-crystal-ball.jpg'}]);
]]>

source="http://mixmatters.com/hot/2008/images/DJ_Flex-Te_Quiero.jpg"
x="{this.list.x + this.list.width}"
y="10"
horizontalAlign="center"
open="progressBar.visible = true"
complete="progressBar.visible = false"
completeEffect="Fade"/>
x="{this.list.x + this.list.width}"
y="10"
source="{image}"
visible="false"
showEffect="Fade"
hideEffect="Fade"/>


image.source = list.selectedItem.data;
]]>




Flex - Slide Menu





layout="absolute"
height="100%" width="100%">




















toState="over1">
target="{this.c1}"
duration="2000"/>

toState="over2">
target="{this.c2}"
duration="2000"/>

toState="over3">
target="{this.c3}"
duration="2000"/>

toState="over4">
target="{this.c4}"
duration="2000"/>

toState="over1-1">
target="{this.c1}"
duration="1000"/>

toState="over2-2">
target="{this.c2}"
duration="1000"/>

toState="over3-3">
target="{this.c3}"
duration="1000"/>

toState="over4-4">
target="{this.c4}"
duration="1000"/>


x="{this.canvas1.x}"
y="{this.canvas1.y}"
width="200"
height="55">


y="23"
width="200"
height="55"
id="canvas1"
mouseOut="this.currentState='over1-1'"
mouseOver="this.currentState = 'over1'">


x="{this.canvas2.x}"
y="{this.canvas2.y}"
width="200"
height="55">


y="96"
width="200"
height="55"
id="canvas2"
mouseOut="this.currentState='over2-2'"
mouseOver="this.currentState = 'over2'">


x="{this.canvas3.x}"
y="{this.canvas3.y}"
width="200"
height="55">


y="168"
width="200"
height="55"
id="canvas3"
mouseOut="this.currentState='over3-3'"
mouseOver="this.currentState = 'over3'">


x="{this.canvas4.x}"
y="{this.canvas4.y}"
width="200"
height="55">


y="242"
width="200"
height="55"
id="canvas4"
mouseOut="this.currentState='over4-4'"
mouseOver="this.currentState = 'over4'">



2010年6月2日 星期三

2010年4月6日 星期二

Flex3 搭配amfphp










2009年7月7日 星期二

2009年7月3日 星期五

Radio Head Japan



超讚分鏡影片
http://www.wowow.co.jp/music/radiohead/special/

2009年5月17日 星期日

使用Flex Code Generator開發Flex+PHP

為加速開發Flex+PHP,於是使用了
FCG : a Flex Code Generator
  • 過往在Java的經驗,寫ORM的model及DAO是最沒價值又費時間的,所以會較依賴generator
  • 此程式在產生對應java的as model時,會有型態無法直接轉換的問題 e.g.java中 BigDecimal 轉到as仍是BigDecimal但as裡沒有BigDecimal型態,不過己可減少蠻多這種重覆又沒義意的工作了
建立過程會分二個階段,我們先來介紹過PHP的部份
  1. 首先直接在該網站使用線上安裝(會直接偵測是否有安裝AIR)
  2. 裝好後先在MySQL建立好了幾張table,再將script export出來
  3. 啟動FCG後在【Main Package Name】輸入自己的full package name <= 這個階段可暫不輸入
  4. 接著選擇【Project Type】 選擇【PHP】 => 【Start Project】
  5. 【Import SQL】 選擇己export出來的table script <= 只可包含Create Table的script
  6. Finish後即可出現即可出現所有的VO及DAO PHP程式
  7. 內容中有一個header.php ,請自行建立所需資料庫相關資訊
待續.......

2009年5月14日 星期四

二個共同寫一支程式(同時間)

XP(Extreme Programming) 提到的 配對編碼(Pair Programming)
eclipse plug-in Eclipse Communication Framework Project
乎似真能做到二個同共寫一支程式,哪天也來試試二個共同寫一支程式帶來的效益
建議用HD看會比較清楚

Cola: Real-Time Shared Editing from Mustafa K. Isik on Vimeo.

2009年5月10日 星期日

Creat second tomcat server using same Tomcat














































































































投影片 320

2009年5月2日 星期六

Android 手機應用程式設計入門by gasolin

    實作上發現書中問題點筆記
    十四章加入選單
  1. 加上後面這段應可讓真沒寫過java的人更容易入手需覆寫實作Activity的method時可由eclipse 原始碼中【滑鼠右鍵】=>【source】=>【override/implement methods....】即可在選單上選擇找到欲覆寫/實作的method,不用去打這個字,避免打錯
  2. 加了二個function(public boolean onCreateOptionsMenu(Menu menu)、public boolean onOptionsItemSelected(MenuItem item))後在emulator上是需要按了 menu後才會出現所加的menu,以上應該也說明一下
  3. 圖示放到 res/drawable 裡的圖檔檔名除了只接受英文字母、數字、或底線 ................我們看到console 上出現res\drawable\Delete.png: Invalid file name: must contain only [a-z0-9_.],所以對己定義的RegExp為檔案不接受大寫字母(所使用版本為 android-sdk-windows-1.1_r1)ps.1.5版也是。

2009年3月22日 星期日

WordPress 多語系

最近在幫User找WordPress多語系問題
找了一下使用 xlanguage plug-in應該可以解決這個問題
http://wordpress.org/extend/plugins/xlanguage/
下載好了xlanguage後解壓到 [WordPress安裝目錄]\wp-content\plugins下
再進入管理者介面後在Setting就會出現這個plugin的選項











點選進入後最主要的是就是 Language及Lauguage這二個項目












設好各個語系的名稱及Locale後
在新增或編寫文章時使用編輯器右上方的1、2、3.....
做不同語系的設定














看一下html,原來是使用了在tag上加上attribute的做法來逹到多語系
(註:可以考慮用在Java的作法哦,以往接觸到的i18N都只有LABEL有多語系)











最後再點 Apperance的Widgets









再把xlanguage加到畫面上就完工了
完成如下所示
繁體:












簡體:












英文:













考慮把這邊的內容搬到WordPress平台ing.......

2009年2月16日 星期一

Flex Code Formatter Plug-In Released

期待己久的Flex Builder Code Formatter功能終於有Plug-in了
請至
http://sourceforge.net/projects/flexformatter/
下載
下載好了把 FlexPrettyCommand_x.x.x.jar
放到Program Files\Adobe\Flex Builder 3\plugins即可






















































可選擇在每次按完 Save鈕就做Format 或是同樣可使用CTRL +SHIFT+F




















等了這麼久真是太感動啦

2009年1月4日 星期日

iCal4j 簡單範例 + Flex Calendar

最近有需要幫 使用者做一工作排程程式
找了一下資源
決定使用Flex 開發
Flex己有己前人開發好的 Calendar 元件
http://blog.flexcommunity.net/?p=11
這個版本是採用了 http://www.quietlyscheming.com/blog/components/interactive-calendar/
所做的修改
排程中主要是使用了iCal 的檔案格式來做事件的排定

於是 找了 iCal4J做成產生iCal的底層程式
http://ical4j.sourceforge.net/introduction.html
請下載了相關的jar檔
開始了第一個簡單的範例

























我所貼的這段 請注意在 第24行的部份
我在Run時一定要有 Method 這個Properties
官網範例沒加 會一直出現 週期性農曆約會儲存為 iCalendar 格式
這個$M說明 講的不是很清楚的怪說明

接著就就把 產生的 .ics 檔案按下步驟放到
Calendar程式中


1) open app_code.as
2) on line 81 insert the path to your .ics file

由FlexBuilder執行即可看到所建立的事件















中文沒法出現 但Tip可出現中文,還在了解ing..........

2008年12月18日 星期四

蔡依林的部落格
























重灌逹人獨孤木
的文章看了一下
發現這是多麼神奇的囧事情
我也來玩一下是不是
會被灌爆呢?
弄個照片上來 看會不會 爆的快點 哈~~
過幾天再來看看這個 囧 威力吧