<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2389124153774442796</id><updated>2026-07-04T02:46:26.225+08:00</updated><category term="FLASHAS3"/><category term="android"/><category term="PV3D"/><category term="medialand"/><category term="AIR"/><category term="Flash10"/><category term="FLASHAS2"/><category term="flashdevelop"/><category term="CoolWeb"/><category term="FLASHCS3"/><category term="FLASHCS4"/><category term="other"/><category term="progression"/><category term="Flex"/><category term="JavaScript"/><category term="adobe"/><category term="components"/><category term="facebook"/><category term="flycan"/><category term="Events"/><category term="FLARToolKit"/><category term="Progression4"/><category term="away3d"/><category term="effect"/><category term="html5"/><category term="unity3d"/><category term="新聞區"/><category term="Fluorine"/><category term="Game"/><category term="designPatterns"/><category term="ios"/><category term="silverlight"/><category term="Flash10.1"/><category term="Flash11"/><category term="Friends"/><category term="MQuery"/><category term="Tweener"/><category term="android layout"/><category term="asp.net"/><category term="createJS"/><category term="extension"/><category term="html"/><category term="puremvc"/><category term="webpack"/><category term="Android App"/><category term="Anteater"/><category term="BlackBerry"/><category term="Dreamweaver"/><category term="FLASHCS5"/><category term="Flare3D"/><category term="Flash"/><category term="Flash10.2"/><category term="Java"/><category term="TweenMax"/><category term="ZedBox"/><category term="catalyst"/><category term="debug"/><category term="flashP2P"/><category term="gulp"/><category term="jQuery"/><category term="line"/><category term="mac"/><category term="milkmidiBook"/><category term="music"/><category term="mxml"/><category term="remoting"/><category term="robotlegs"/><category term="starling"/><category term="study"/><category term="userInterface"/><category term="virtual3d"/><category term="vscode"/><category term="vue"/><category term="youtube"/><category term="刷機"/><category term="開發人員小工具"/><title type='text'>milkmidi Blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>371</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-1218268728677633750</id><published>2018-11-03T14:29:00.002+08:00</published><updated>2018-11-03T14:29:49.171+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="line"/><title type='text'>[JS] line 分享</title><content type='html'>&lt;div class=&quot;fullpost&quot;&gt;
大家好，我是奶綠茶&lt;br /&gt;
在網頁想要做 line 分享&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;
// desktop
// 可以帶 url
// 帶 text (有字數長度限制)
window.open(`https://lineit.line.me/share/ui?url=${encodeURIComponent(url)}&amp;amp;text=${encodeURIComponent(text)}`);

// mobile
// 只有　text ，但可以把網址帶入文字，他會自已解悉
window.open(`line://msg/text/${encodeURIComponent(text)}`, &#39;_blank&#39;);


// 第三種方法, 桌手機都支援，但有些問題
// 手機在 line, FB webview ，一樣可以分享，但網頁會被轉到 &quot;請啟動 LINE 應用程式，使用者就會跳離現在的網頁
// 而在桌機會遇到如果分享的網址和你目前所在的網址 domain 不同
// 分享文章裡就會自動帶出目前所在的網址
// 如果 domain 相同，但在文字裡又加入了想要分享的網址
// 最終分享出去就會出相兩個網同的網址(有些人，有些人不會，Why?)
window.open(`http://line.me/R/msg/text/?${encodeURIComponent(this.url)}`);
&lt;/code&gt;
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/1218268728677633750/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/1218268728677633750' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/1218268728677633750'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/1218268728677633750'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2018/11/js-line.html' title='[JS] line 分享'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-4635300173270915509</id><published>2017-07-15T08:13:00.004+08:00</published><updated>2017-07-15T08:13:51.825+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="vscode"/><title type='text'>aliases in Window command </title><content type='html'>大家好，我是奶綠茶&lt;br /&gt;
身為前端，每天最常打的指令就是&lt;br /&gt;
npm run start&lt;br /&gt;
npm run build&lt;br /&gt;
npm run 什麼的&lt;br /&gt;
在 Mac 可以方便的將指令設定別名縮寫&lt;br /&gt;
那 PC 上呢 ?&lt;br /&gt;
可以用&amp;nbsp;doskey ns=npm run start&lt;br /&gt;
但每次啟動 cmd 都要重新設定&lt;br /&gt;
可以透過以下方法整合到 vsCode&lt;br /&gt;
設定你的 ailases&lt;br /&gt;
奶綠我將檔案放在 E:\aliases.cmd&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;
@echo off
doskey n=npm run $*
doskey ns=npm run start
doskey nb=npm run build
doskey s=npm run start
doskey b=npm run build
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
開啟 vsCode Settings.json, 加入以下設定&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;
 &quot;terminal.integrated.shellArgs.windows&quot;: [
    &quot;/k&quot;,
    &quot;e:\\aliases.cmd&quot;
  ]
&lt;/code&gt;&lt;/pre&gt;
好了，這樣每次開啟 terminal 就可以有縮寫功能&lt;br /&gt;
轉載請註明出處</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/4635300173270915509/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/4635300173270915509' title='5 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/4635300173270915509'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/4635300173270915509'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2017/07/aliases-in-window-command.html' title='aliases in Window command '/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-7616675537047280350</id><published>2017-07-02T11:38:00.002+08:00</published><updated>2017-07-02T11:45:06.619+08:00</updated><title type='text'>超好用的無限免費網頁空間，無廣告，無流量限制</title><content type='html'>&lt;div class=&quot;fullpost&quot;&gt;
大家好，我是奶綠茶&lt;br /&gt;
今天來教大家如何申請一個無限免費速度又快的網頁空間&lt;br /&gt;
1 首先到&amp;nbsp;&lt;a href=&quot;https://github.com/&quot; target=&quot;_blank&quot;&gt;https://github.com/&lt;/a&gt; 申請帳號(一直下一步，下一步，下一步)&lt;br /&gt;
2 到你的個人頁，切換上方的 tab 到 Repositories, 按下右鍵的 new&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;201&quot; data-original-width=&quot;987&quot; height=&quot;128&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNLAx4_mpsXmeVilMTF5mVUGQKSU6bYBhhnxWAHQYQmgxrM7yxrhdkqXqofg28IRmte_zqij1tTxKCpXP1uhQhU7U0njkL_rfCKFWtipVe002HT1gdk0-gVbj8_Cp4rCTvctA9YYbj5Q4/s640/2017-07-02_105637.png&quot; width=&quot;640&quot; /&gt;
&lt;br /&gt;
3 Repository name&lt;br /&gt;
一定要是這樣的格式 username.github.io&lt;br /&gt;
我的 github 網址是 github.com/milkmidi&lt;br /&gt;
那就要輸入 milkmidi.github.io&lt;br /&gt;
選擇 public, 這樣別人才看的到&lt;br /&gt;
private 有其他用途, 而且要付費才能使用&lt;br /&gt;
完成後按下 Create repository&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;593&quot; data-original-width=&quot;720&quot; height=&quot;526&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix8qOd6AKq-2Ot99xwBCKWywVpawpmygzRwJ1U_cdln46MUdZZVV7SFbWMqD-wFL3vipp4EYKpBluPtn84NMY6g9nNXShvdr8MKRPy2gc7hr6WQ2m7-RhDSbeFC9M0iHoA2MFkIUrdL98/s640/2017-07-02_105855.png&quot; width=&quot;640&quot; /&gt;

&lt;br /&gt;
&lt;br /&gt;
5 安裝 SourceTree&lt;br /&gt;
github 並不支援 FTP 或是網頁上傳，一定要透過指令碼&lt;br /&gt;
在這我們選用有圖型介面的軟體，方便大家學習&lt;br /&gt;
&lt;a href=&quot;https://www.sourcetreeapp.com/&quot; target=&quot;_blank&quot;&gt;https://www.sourcetreeapp.com/&lt;/a&gt;&lt;br /&gt;
下載並安裝&lt;br /&gt;
啟動後登入你的 github 帳號&lt;br /&gt;
&lt;br /&gt;
6 clone 你的 github io 專案&lt;br /&gt;
右上角有個 Clone or download 點選後&lt;br /&gt;
複製 https 連結(不要選到 ssh )&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;345&quot; data-original-width=&quot;396&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNa71nG8blaKt3taBfbMpCcJmoRzJtKb2cB0gJeDgeryHjnpxA4fQIoBjS-fmgr28XC6gENXgP0LcZZt6uZU62EIUc-10Q3lWXAT2fnW1Sic3flWNxooqD9pXHhfrE3CTkH49BSOMH9Io/s1600/2017-07-02_112352.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
7 將 https 的連結貼到 SourceTree&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;423&quot; data-original-width=&quot;618&quot; height=&quot;272&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjufVimlRN7pqCig01z0CIKQ76FRjHj0TJfDtCYJ6QIOxi1Dm6VDtku50AQtoi91txXer1mXShtdnSeaHM0L7QH1SJZ4ZF1G-dGbyGhXqjX6s8LIA07YkAjOUDJs59mzglyWJf9APyf_00/s400/2017-07-02_112309.png&quot; width=&quot;400&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
8 上傳 html&lt;br /&gt;
到本機 github.io 資料夾，放一個 index.html&lt;br /&gt;
切換到 SourceTree, 這時會看到 Unstaged files 的欄位&lt;br /&gt;
選擇 Stage All&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;648&quot; data-original-width=&quot;712&quot; height=&quot;363&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYH54gik6YUW-M197MeSV-u5GPDe1T_EzSxHyGc_rcxM2lw-NSPmvMVVGPBcXkErso-L8XOF_S5Gf2AMrsjRUhIpHy7IdTWL1i76XFokkxBNeSnA0nJO3zmFlDkjuxK0saDU59PSFawzk/s400/2017-07-02_113249.png&quot; width=&quot;400&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
9 git 要求每次的 Commit, 都一定要打說明文字(好習慣)&lt;br /&gt;
輸入完成後，按下右邊的 Commit&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;618&quot; data-original-width=&quot;685&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBbj_D2YCeIW0cQRA5R9EtzcSctM7cZswXQH4vKwA-Ne3GDhRv88B3vGHTb21_wDe-IsrOGYLTCUfcZRytJ_T7gwHgMPRTBAPj1Uva1nRK4PbNxDOiXXYZSkjDKmyzDuMrM88V7ZyhVKU/s400/2017-07-02_113258.png&quot; width=&quot;400&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
10 發佈(Push)，這樣就完成啦&lt;br /&gt;
可以到你的&amp;nbsp;http://milkmidi.github.io/ 去查看檔案有沒有出來&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnoI7JJjvPSMC81vTcqIxpyOIvkidajvP_br0Y51-JlO5OCfCNTrVtJ41GHRwrf5XDGgOGAjX4ibdkqSjjj_o6mJWeSSYN5IUxPGY_ChLJqgzDlq_zM1MI37NJ3xd0BXikSytTs4bs0fM/s320/2017-07-02_113604.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
其他&lt;br /&gt;
Commit 可以想像是做一個記錄，你可以很多的 Commit&lt;br /&gt;
最後再一次 Push 上去&lt;br /&gt;
github 原本是給程式設計師用的版本控管服務&lt;br /&gt;
免費版提供無限空間讓你放檔案，但一定要是 public&lt;br /&gt;
想要有私有的 Project ，就只能付費&lt;br /&gt;
github.io 只能放靜態檔案，php, aspx 服務並不支援。&lt;br /&gt;
祝大家學習愉快&lt;br /&gt;
&lt;br /&gt;
轉載請註明出處 &lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://github.com/milkmidi/milkmidi.github.io&quot; target=&quot;_blank&quot;&gt;奶綠的 github.io Source Code&lt;/a&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/7616675537047280350/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/7616675537047280350' title='2 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/7616675537047280350'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/7616675537047280350'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2017/07/blog-post.html' title='超好用的無限免費網頁空間，無廣告，無流量限制'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNLAx4_mpsXmeVilMTF5mVUGQKSU6bYBhhnxWAHQYQmgxrM7yxrhdkqXqofg28IRmte_zqij1tTxKCpXP1uhQhU7U0njkL_rfCKFWtipVe002HT1gdk0-gVbj8_Cp4rCTvctA9YYbj5Q4/s72-c/2017-07-02_105637.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-2975289524097670182</id><published>2017-06-26T09:59:00.002+08:00</published><updated>2017-06-26T10:02:54.289+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="mac"/><title type='text'>mac backspace char ASCII 08</title><content type='html'>大家好，我是奶綠茶&lt;br /&gt;
最近在 mac 上踩到一個雷&lt;br /&gt;
不知道在什麼情況下，文字會多出一個 backspace 元字&lt;br /&gt;
在 PC 上會出現一個黑圓點&lt;br /&gt;
偏偏 VSCode 預設是不會顯示( Sublime 會出現白底黑字的BS標示)&lt;br /&gt;
然後被包在 JS 裡的字串，一切就爆掉了。&lt;br /&gt;
解法 VSCode 在&lt;br /&gt;
View / Toggle Control Character&lt;br /&gt;
這樣該字元就會顯示一個小字的 BS&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;46&quot; data-original-width=&quot;308&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfL9NYqJTN_3KlZv2k6-RRcvbTCi9gAL1UMJREdRRBMbIr37RyOwlql8hXUbmasY6imn-hGLRNa8iPyxzezEUmblPVO4bDffR8oGYP5uBHqE7YLYUj4asADJPShnX86gjADanDaZdNLUk/s1600/%25E8%259E%25A2%25E5%25B9%2595%25E5%25BF%25AB%25E7%2585%25A7+2017-06-26+%25E4%25B8%258A%25E5%258D%25889.58.40.png&quot; /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/2975289524097670182/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/2975289524097670182' title='1 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/2975289524097670182'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/2975289524097670182'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2017/06/mac-backspace-char-ascii-08.html' title='mac backspace char ASCII 08'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfL9NYqJTN_3KlZv2k6-RRcvbTCi9gAL1UMJREdRRBMbIr37RyOwlql8hXUbmasY6imn-hGLRNa8iPyxzezEUmblPVO4bDffR8oGYP5uBHqE7YLYUj4asADJPShnX86gjADanDaZdNLUk/s72-c/%25E8%259E%25A2%25E5%25B9%2595%25E5%25BF%25AB%25E7%2585%25A7+2017-06-26+%25E4%25B8%258A%25E5%258D%25889.58.40.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-5841153380616690797</id><published>2017-04-15T15:05:00.001+08:00</published><updated>2017-04-15T15:05:25.308+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gulp"/><title type='text'>gulp 前端自動化 - spritesheet </title><content type='html'>&lt;div class=&quot;fullpost&quot;&gt;
大家好，我是奶綠茶&lt;br /&gt;
今天來介紹如何使用 gulp 來自動化將圖片拼成 spritesheet&lt;br /&gt;
奶綠我使用的套件是 gulp.spritesmith&lt;br /&gt;
&lt;a href=&quot;https://www.npmjs.com/package/gulp.spritesmith&quot; target=&quot;_blank&quot;&gt;https://www.npmjs.com/package/gulp.spritesmith&lt;/a&gt;&lt;br /&gt;
可以使用&amp;nbsp;handlebars 格式，拼出自己想要的 css 格式&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;
{{#sprites}}
.{{name}} {
    background-position: {{px.offset_x}} {{px.offset_y}};
    width: {{px.width}};
    height: {{px.height}};
    background-image: url({{{escaped_image}}});
}
{{/sprites}}
&lt;/code&gt;
&lt;/pre&gt;
gulp 的設定
&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;
gulp.task(&#39;sprite&#39;,()=&amp;gt;{
    console.log(&#39;sprite&#39;);
    const spriteData = gulp.src(&#39;src/sprite_src/*&#39;)
        .pipe(spritesmith({
            imgName: &#39;../img/sprite.png&#39;,
            cssName: &#39;_sprite.css&#39;,
            padding: 4,
            imgOpts: { quality: 100 },
            cssTemplate: &#39;src/css/handlebars/basic.handlebars&#39;,
        }));
    const imgStream = spriteData.img
        .pipe(buffer())
        .pipe(gulp.dest(&#39;dist/img/&#39;));

    const cssStream = spriteData.css
        .pipe(gulp.dest(&#39;src/css&#39;));
    return merge(imgStream, cssStream);
});
&lt;/code&gt;&lt;/pre&gt;
發佈後，就會產生對映的圖片和css檔&lt;br /&gt;
&lt;br /&gt;
問題&lt;br /&gt;
在製作按鈕圖案時，都會把一般和hover的圖合拼在一張&lt;br /&gt;
這樣在 :hover 時只要指定 background-position:bottom 就可以&lt;br /&gt;
但現在經過合拼成 spritesheet 時，background-position 座標會有問題&lt;br /&gt;
所以我們來修正一下&lt;br /&gt;
在合拼時，判斷如果檔名有 _btn 就套用新的規則&lt;br /&gt;
新增 ifIndexOfBTN 表籤，加入自定的函式&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;
{{#sprites}}
{{#ifIndexOfBTN name}}
.{{name}} {    
    background-position: {{px.offset_x}} {{px.offset_y}};
    width: {{px.width}};
    height: {{half height}};    }
    .{{name}}:hover {   background-position:{{px.offset_x}} {{hoverPosition offset_y height}};   }
{{else}}
.{{name}} {    
    background-position: {{px.offset_x}} {{px.offset_y}};
    width: {{px.width}};
    height: {{px.height}};  }

{{/ifIndexOfBTN }}
{{/sprites}}
&lt;/code&gt;
&lt;/pre&gt;
更新gulp&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;
.pipe(spritesmith({
 略 
 cssTemplate: &#39;src/css/handlebars/basic.handlebars&#39;,
 cssHandlebarsHelpers: {
  ifIndexOfBTN(name, options) {
   if (name.indexOf(&#39;_btn&#39;) !== -1) {
    return options.fn(this);
   }
   return options.inverse(this);
  },
  hoverPosition(position, height) {
   return `${position - (height / 2)}px`;
  },
  half(num) {
   return `${Math.floor(num / 2)}px`;
  },
 },
}));
&lt;/code&gt;
&lt;/pre&gt;
handlebar 遇到自定的 tag 或是函式時&lt;br /&gt;
就會到 spritesmith 裡的 cssHandlebarsHelpers 去找對映的函式&lt;br /&gt;
完成。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
轉載請註明出處 &lt;br /&gt;
&lt;a href=&quot;https://github.com/milkmidi/front_end_tutorial/tree/master/03_gulp_spritesmith&quot; target=&quot;_blank&quot;&gt;Github Source Code&lt;/a&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/5841153380616690797/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/5841153380616690797' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/5841153380616690797'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/5841153380616690797'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2017/04/gulp-spritesheet.html' title='gulp 前端自動化 - spritesheet '/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-66283472816406723</id><published>2017-04-05T12:09:00.002+08:00</published><updated>2017-04-05T12:09:22.660+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="vue"/><category scheme="http://www.blogger.com/atom/ns#" term="webpack"/><title type='text'>2017 線上讀書會- vuex 跟 webpack 與 架構範本</title><content type='html'>&lt;div class=&quot;fullpost&quot;&gt;
分享一下奶綠我在 2017 02 線上讀書會&lt;br /&gt;
主講 vuex , webpack 的影片&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/eX54AJFzxXU&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;

&lt;br /&gt;
轉載請註明出處 &lt;br /&gt;
&lt;a href=&quot;https://github.com/milkmidi/2017_vue_vuex_hello_world&quot; target=&quot;_blank&quot;&gt;Github Source Code&lt;/a&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/66283472816406723/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/66283472816406723' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/66283472816406723'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/66283472816406723'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2017/04/2017-vuex-webpack.html' title='2017 線上讀書會- vuex 跟 webpack 與 架構範本'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/eX54AJFzxXU/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-4936257252760905486</id><published>2017-03-29T11:25:00.002+08:00</published><updated>2017-03-29T11:25:15.197+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="webpack"/><title type='text'>webpack2 入門實戰 3 scss,html,file-loader</title><content type='html'>&lt;div class=&quot;fullpost&quot;&gt;
大家好，我是奶綠茶&lt;br /&gt;
&lt;a href=&quot;http://milkmidi.blogspot.tw/2017/03/webpack2-2-loader.html&quot;&gt;上一篇&lt;/a&gt;介紹了 webpack 的核心功能 loader&lt;br /&gt;
這篇再來補強各種常用的 loader&lt;br /&gt;
css-loader：解悉 css 檔&lt;br /&gt;
extract-loader：這個有點難翻，下面會介紹&lt;br /&gt;
file-loader：存成實體的檔案, 如圖片&lt;br /&gt;
html-loader：解悉 html 檔&lt;br /&gt;
sass-loader：解悉 scss 檔&lt;br /&gt;
url-loader：解悉圖片路徑&lt;br /&gt;
webpack.config.js&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;
module.exports = {
    resolveLoader: {
        // 所有用到的 loader,  -loader 可以不用打
        moduleExtensions: [ &quot;-loader&quot; ], 
    },
    resolve: {
        // 在 require 檔案, 如果不想寫完整的路徑
        // 可以加入這些目錄, 讓 webpack 自動尋找對的檔案
        // 請注意我們加入了 src/img 路徑，後面會再介紹到
modules: [  
            path.resolve( &#39;src/html&#39; ),
            path.resolve( &#39;src/img&#39; ),
            path.resolve( &#39;src/css&#39; ),
            path.resolve( &#39;src/js&#39; ),
            path.resolve( &quot;node_modules&quot;),
        ],
        // 在 require 時可以不用打副檔名
        extensions: [ &quot;.js&quot;, &quot;.scss&quot; ] 
    },
}
&lt;/code&gt;&lt;/pre&gt;
再來就是 loader 的介紹&lt;br /&gt;
scss&lt;br /&gt;
在這要做多組合的應用&lt;br /&gt;
先將 .scss 透過 scss-loader 轉換, 並產生 sourceMap 檔&lt;br /&gt;
再過 css-loader&lt;br /&gt;
最後再過 style-loader
&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;
{
 test: /\.scss$/,
 // 多個 loader 組合, 可寫成一行，或是使用 use, 
 // 處理順序是由後往前
 // loader: &#39;style!css?sourceMap!sass?sourceMap&#39;,
 use: [
  &quot;style&quot;,                    
  &quot;css?sourceMap&quot;,
  &#39;sass?sourceMap&#39;
 ],
 include: path.resolve( __dirname, &quot;src/css&quot; ),
 exclude: /(node_modules|bower_components)/,
},

&lt;/code&gt;
&lt;/pre&gt;
html&lt;br /&gt;
最終要產生實體的 html 檔&lt;br /&gt;
1. 直接用 file-loader 產生&lt;br /&gt;
會發現 html 變成了 js code&lt;br /&gt;
而且圖片也沒有處理&lt;br /&gt;
2. 過 extract-loader&lt;br /&gt;
再過 file-loader ,&lt;br /&gt;
產生的 html 才是我們要的&lt;br /&gt;
那圖片是怎麼處理的呢?&lt;br /&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;{
 // https://github.com/webpack-contrib/html-loader
 test: /\.html$/,
 // 只用 html-loader , 會把 html 的 code 包在 js 裡，不是我們要的
 // loader: &#39;html&#39;, 
 // 只用 file-loader , 只會單純的 copy 過去, 不會處理 img src 的圖片
 // loader: &#39;file?name=[name].html&#39;, 
 loader: &#39;file?name=[name].[ext]!extract!html&#39;,
 include: [ path.resolve( __dirname, &quot;src/html&quot; ) ],
 exclude: /(node_modules|bower_components)/,
},

&lt;/code&gt;
&lt;/pre&gt;
jpg,png圖片&lt;br /&gt;
extract-loader 或是 css-loader ,遇到圖片路徑,&lt;br /&gt;
會再轉給 webpack 其他的 loader 處理&lt;br /&gt;
正規副檔名是 png,jpg,gif,svg,ico 就使用 url-loader&lt;br /&gt;
如果圖片小於 2048k 就轉成 base64 字串&lt;br /&gt;
否則就自動改用 file-loader 來處理&lt;br /&gt;
這部份就是 webpack 的強項&lt;br /&gt;
同檔名圖片，會因為使用者快取，看不到你更新的圖片&lt;br /&gt;
所以在 name 的參數，加入了一個 hash 參數&lt;br /&gt;
本來的 html img src=&quot;xxxxx.jpg&quot;&lt;br /&gt;
經過 url-loader 轉換後, 就變成 &quot;xxx.jpg?f5240920e4&quot;&lt;br /&gt;
而且只有過 url-loader 的圖片，才會被處理&lt;br /&gt;
最終上線的圖片，就只會有用到的圖片檔&lt;br /&gt;
&lt;br /&gt;
小技巧&lt;br /&gt;
在 html, css 要寫圖片路徑，以前都要寫完整的相對路徑&lt;br /&gt;
在 webpack 下，可以縮寫成 &quot;~xxxx.jpg&quot; ，前面加入小蚯蚓&lt;br /&gt;
記得在 resolve modules 加入圖片路徑&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;
{
 test: /\.(png|jpg|gif|svg|ico)$/,
 use: [
  {
   loader: &#39;url&#39;,
   options: {
    // 小於 2048k 的圖檔, 自動變成 base64 字串
    limit: 2048,
    // 檔名： asset/[字資料夾][檔名].[副檔名]?[檔案的hash]
    name: &quot;asset/[path][name].[ext]?[hash:10]&quot;,
   },
  },
 ],
 include: path.resolve( &#39;src/img&#39; ),
 exclude: /(node_modules|bower_components)/,
},

&lt;/code&gt;
&lt;/pre&gt;
webpack 打包後, 就可以看到最終產生的所有檔案&lt;br /&gt;
等一下!!!!!!!!!!!!!!!!! 怎麼沒有 css 檔 ??&lt;br /&gt;
因為目前的 scss 設定，預設會把 style 通通都寫在 js 檔裡&lt;br /&gt;
並在執行網頁時, 動態的注到 style tag 到你的 html&lt;br /&gt;
如果想產生實體的 css 檔，我們的 loader 規則就要換一下&lt;br /&gt;
&lt;br /&gt;
回去看一下剛剛的 scss 設定&lt;br /&gt;
我們採用的組合是 style!css!scss&lt;br /&gt;
其中的 style-loader 就是產生 js 注入用的程式碼&lt;br /&gt;
改用&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;
{
 test: /\.scss$/,
 use: [
  // &quot;style&quot;, // 如果要用 extract-loader , 就不要加 style-loader
  &quot;file?name=asset/[path][name].css&quot;,
  &quot;extract?publicPath=../../&quot;,
  &quot;css?sourceMap&quot;,
  &#39;sass?sourceMap&#39;
 ],
 include: path.resolve( __dirname, &quot;src/css&quot; ),
 exclude: /(node_modules|bower_components)/,
},
&lt;/code&gt;
&lt;/pre&gt;
小結一下&lt;br /&gt;
webpack 每個 loader 都只做一件事&lt;br /&gt;
有時要產生想要的結果，需要用多組 loader 組合&lt;br /&gt;
&lt;br /&gt;
轉載請註明出處 &lt;br /&gt;
&lt;a href=&quot;https://github.com/milkmidi/webpack2_example/tree/master/03&quot; target=&quot;_blank&quot;&gt;Github Source Code&lt;/a&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/4936257252760905486/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/4936257252760905486' title='2 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/4936257252760905486'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/4936257252760905486'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2017/03/webpack2-3-scsshtmlfile-loader.html' title='webpack2 入門實戰 3 scss,html,file-loader'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-153059219378522961</id><published>2017-03-28T14:31:00.002+08:00</published><updated>2017-03-28T14:34:55.891+08:00</updated><title type='text'>webpack2 入門實戰 2 loader 篇</title><content type='html'>&lt;div class=&quot;fullpost&quot;&gt;
大家好我是奶綠茶&lt;br /&gt;
&lt;a href=&quot;http://milkmidi.blogspot.tw/2017/03/webpack2-1.html&quot;&gt;上一篇&lt;/a&gt;介紹到基本的 webpack2 使用&lt;br /&gt;
這篇來介紹 webpack 的核心功能 loader&lt;br /&gt;
要告訴 webpack , 遇到什麼樣的檔案, 要用什麼樣的 loader 處理&lt;br /&gt;
我們就以 babel-loader 來做教學&lt;br /&gt;
1. 安裝 babel-loader&lt;br /&gt;
babel-core：babel 的核心程式&lt;br /&gt;
babel-loader：webpack 用的 babel 轉換 loader&lt;br /&gt;
babel-preset-es2015：babel 轉換成相下相容的語法&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;
npm i -s -D babel-loader babel-core babel-preset-es2015
&lt;/code&gt;
&lt;/pre&gt;
2. webpack.config.js&lt;br /&gt;
所有的 loader 規則都放在 module.rules 下&lt;br /&gt;
test：正則比對副檔名，只要是 .js 或 .jsx 都套用這個 loader&lt;br /&gt;
loader：指定要套用的 loader&lt;br /&gt;
options:要傳給 loader 的參數&lt;br /&gt;
注：loader寫法有二種，寫成一行, 用 ? 當參數傳&lt;br /&gt;
另一種就是寫 loader , 然後用 options 傳&lt;br /&gt;
個人比較愛後者&lt;br /&gt;
include：該 loader 只要找指定的資料夾，可加速 webpack 打包&lt;br /&gt;
exclude：同理，只是排除資料夾&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;
var path = require( &#39;path&#39; );
module.exports = {
    context: path.join( __dirname, &#39;/src&#39; ),
    entry: &#39;./js/app.js&#39;,
    output: {
        filename: &#39;bundle.js&#39;,
        path: path.resolve( __dirname, &#39;dist&#39; )
    },
    module: {   //https://webpack.js.org/configuration/module/
        rules: [
            {
                test: /\.(js|jsx)$/,
                // 寫法 1, xx-loader?參數
                // loader: &#39;babel-loader?presets[]=es2015&#39;
                // 寫法 2 , loader + options
                loader: &#39;babel-loader&#39;, 
                options: {
                    // 轉成es2015格式，支援舊的 Browser
                    presets: [ &#39;es2015&#39; ], 
                },
                // 只找這個資料夾下的檔案，可以加速 webpack 打包
                // 如果要多路徑, 可以寫成 Array
                include: path.resolve( __dirname, &quot;src/js&quot; ),
                // 排除文件，加速 webpack 打包
                exclude: /(node_modules|bower_components)/, 
            },
        ]
    }
};
&lt;/code&gt;
&lt;/pre&gt;
3. app.js 採用 es6 的各種新語法寫&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;class MyApp {
    constructor() {
        console.log(&#39;MyApp constructor&#39;);
    }
    foo() {
        console.log(&#39;foo&#39;);
    }
}

var app = new MyApp();

(() =&amp;gt; {
    console.log(&#39;arrow function&#39;);
})();

let name = &quot;milkmidi&quot;;
console.log(`${name} hi`);
&lt;/code&gt;
&lt;/pre&gt;
4. 執行 webpack , 就可以看到 bundle 後的檔, 並且轉成向下相容的js 語法&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
轉載請註明出處 &lt;br /&gt;
&lt;a href=&quot;https://github.com/milkmidi/webpack2_example/tree/master/02&quot; target=&quot;_blank&quot;&gt;Github Source Code&lt;/a&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/153059219378522961/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/153059219378522961' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/153059219378522961'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/153059219378522961'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2017/03/webpack2-2-loader.html' title='webpack2 入門實戰 2 loader 篇'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-2021220247501557378</id><published>2017-03-28T12:07:00.001+08:00</published><updated>2017-03-28T12:08:36.094+08:00</updated><title type='text'>webpack2 入門實戰 1 </title><content type='html'>&lt;div id=&quot;fullpost&quot;&gt;
大家好，我是奶綠茶&lt;br /&gt;
前端戰場不再只是寫寫 js / css , 各種框架、前處理工具百花齊放&lt;br /&gt;
身為前端工程師，不只要把程式寫完，還要寫好&lt;br /&gt;
老師說：選對好工具，事情就完成一半&lt;br /&gt;
如果你還在一隻 JS 打完全部程式，一隻 css 寫所有的 style&lt;br /&gt;
每次存檔還在手動 reload 網頁, 圖片壓 K 壓到不要不要的&lt;br /&gt;
透過奶綠伯的系列教學，讓你了解 webpack2 帶來的優勢&lt;br /&gt;
學會 webpack 可能不會加薪，但至少可以準時下班(誤)&lt;br /&gt;
1. 安裝 nodejs&lt;br /&gt;
請參考 &lt;a href=&quot;http://milkmidi.blogspot.tw/2017/02/2-gulp.html&quot;&gt;gulp&lt;/a&gt; 安裝編&lt;br /&gt;
&lt;br /&gt;
2. 安裝 global webpack , 筆者使用的是 2.2.1 版本&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;
npm i webpack@2.2.1 -g
&lt;/code&gt;
&lt;/pre&gt;
&lt;br /&gt;
3. 在專案的根目錄放一隻 webpack.config.js&lt;br /&gt;
entry：你的主 js 進入點&lt;br /&gt;
output.filename：webpack 打包後的檔名&lt;br /&gt;
output.path：webpack 打包後的路徑&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;
var path = require(&#39;path&#39;);
module.exports = {
    entry: &#39;./src/app.js&#39;,
    output: {
        filename: &#39;bundle.js&#39;,
        path: path.resolve(__dirname, &#39;dist&#39;)
    }
};
&lt;/code&gt;
&lt;/pre&gt;
&lt;br /&gt;
4. require , module.exports&lt;br /&gt;
現在前端都 module 化&lt;br /&gt;
可以每個獨立的功能都寫成單一的 js module&lt;br /&gt;
除了好管理，也方便讓團隊使用&lt;br /&gt;
寫一隻 module_exports_util.js&lt;br /&gt;
每隻經過 webpack 打包的 js , 都會是獨立的檔案&lt;br /&gt;
所以變數都是私有的, 外部成員都無法得到&lt;br /&gt;
在這個 module 裡，我們想開放二個函式&lt;br /&gt;
add , getName&lt;br /&gt;
所以在最後的 module.exports 指定&lt;br /&gt;
筆記加入 jsdoc , 為了方便在開發時，能夠有型別的提示&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;
var name = &quot;milkmidi&quot;;
/**
 * @param {number} num1
 * @param {number} num2
 * @return {number}
 */
function add( num1, num2 ) {
    return num1 + num2;
}

/**
 * @return {string} name
 */
function getName() {
    return name;
}
module.exports = { add , getName };
&lt;/code&gt;
&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
5. 程式進入點 app.js&lt;br /&gt;
使用 require 把剛剛寫好的 module 載入(副檔名是js的話，可以不用寫)&lt;br /&gt;
就可以使用 module 裡設定好的公開函式&lt;br /&gt;
將滑鼠移到 add 函式上，可以看到完整的型別提示&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3kjO4AhRLfWkJuRiM1Bn_MVdAmVbXGHeLVIMIPj3cMjZT1ZEQdVt27uG9l-WWwqHQBWsoZNYz9TDCUd0CvUgnTqSyTO3pBqIbKYWrexdd_2qFUgDm2JO2mQjRSUxWM67axQj3c3ctDWk/s1600/2017-03-28_115306.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3kjO4AhRLfWkJuRiM1Bn_MVdAmVbXGHeLVIMIPj3cMjZT1ZEQdVt27uG9l-WWwqHQBWsoZNYz9TDCUd0CvUgnTqSyTO3pBqIbKYWrexdd_2qFUgDm2JO2mQjRSUxWM67axQj3c3ctDWk/s1600/2017-03-28_115306.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;
var util = require(&quot;./module_exports_util&quot;);
console.log(&quot;util.add&quot;, util.add(1, 1));
console.log(&quot;util.getName&quot;, util.getName());
&lt;/code&gt;
&lt;/pre&gt;
6. 打開專案的 terminal , 輸入 webpack&lt;br /&gt;
webpack 就會自動抓取預設的 webpack.config.js 來打包你的檔案&lt;br /&gt;
打開 bundle.js, 就可以看到 webpack 打包後的程式碼。&lt;br /&gt;
&lt;br /&gt;
7. import , export&lt;br /&gt;
除了 require 的寫法, webpack 也支援 es6 的 import, export&lt;br /&gt;
這次我們直接在 function 前加入 export 關鍵字&lt;br /&gt;
export_util.js&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;/**
 * @param {number} num1
 * @param {number} num2
 */
export function sub( num1, num2 ) {
    return num1 - num2;
}
/**
 * @param {number} num1
 * @param {number} num2
 */
export function multi( num1, num2 ) {
    return num1 * num2;
}
&lt;/code&gt;
&lt;/pre&gt;
&lt;br /&gt;
app.js 新增&lt;br /&gt;
&lt;pre&gt;如果想一次把 module 裡 export 的函式找出&lt;/pre&gt;
&lt;pre&gt;可以寫&lt;/pre&gt;
&lt;pre&gt;import *as 自定變數 from &#39;./export_util&#39;;&lt;/pre&gt;
&lt;pre&gt;如果只是單獨的取一個 export 的函式&lt;/pre&gt;
&lt;pre&gt;import {multi} from &#39;./export_util&#39;;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;
// impprt
import * as u from &quot;./export_util&quot;;
console.log(&quot;sub&quot;, u.sub(5, 2));

import { multi } from &quot;./export_util&quot;;
console.log(&quot;multi&quot;, multi(6, 2));&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
個人是比較愛用 import, export 的寫法&lt;br /&gt;
&lt;br /&gt;
問題 ?&lt;br /&gt;
那可以 require &amp;nbsp;+ export 嗎?&lt;br /&gt;
可以 import&amp;nbsp;+ module.exports 嗎 ?&lt;br /&gt;
大家可以自己試試看就會知道結果&lt;br /&gt;
記得多去看 bundle 後的 js 檔，就會知道原理&lt;br /&gt;
轉載請註明出處 
&lt;br /&gt;
&lt;a href=&quot;https://github.com/milkmidi/webpack2_example/tree/master/01&quot; target=&quot;_blank&quot;&gt;Github Source Code&lt;/a&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/2021220247501557378/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/2021220247501557378' title='2 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/2021220247501557378'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/2021220247501557378'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2017/03/webpack2-1.html' title='webpack2 入門實戰 1 '/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3kjO4AhRLfWkJuRiM1Bn_MVdAmVbXGHeLVIMIPj3cMjZT1ZEQdVt27uG9l-WWwqHQBWsoZNYz9TDCUd0CvUgnTqSyTO3pBqIbKYWrexdd_2qFUgDm2JO2mQjRSUxWM67axQj3c3ctDWk/s72-c/2017-03-28_115306.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-1894412712754935523</id><published>2017-02-05T09:28:00.005+08:00</published><updated>2017-02-05T09:30:02.351+08:00</updated><title type='text'>前端攻城屍自動化教學 2 ( gulp 安裝篇)</title><content type='html'>&lt;div id=&quot;fullpost&quot;&gt;
大家好，我是奶綠茶&lt;br /&gt;
上一篇介紹了現成的前端工具 &lt;a href=&quot;http://milkmidi.blogspot.tw/2016/08/1-prepros.html&quot; target=&quot;_blank&quot;&gt;prepros&lt;/a&gt;&lt;br /&gt;
但總是有些功能無法滿足&lt;br /&gt;
這篇就來介紹純手工的前端自動化工具 gulp&lt;br /&gt;
gulp 的官網一進去就會看到大大的&lt;br /&gt;
Automate and enhance your workflow&lt;br /&gt;
&lt;a href=&quot;http://gulpjs.com/&quot; target=&quot;_blank&quot;&gt;http://gulpjs.com/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
1.&lt;br /&gt;
首先要安裝 npm (nodejs package manager)&lt;br /&gt;
安裝 nodejs 就會有 npm 的功能&lt;br /&gt;
&lt;a href=&quot;https://nodejs.org/en/&quot; target=&quot;_blank&quot;&gt;https://nodejs.org/en/&lt;/a&gt;&lt;br /&gt;
測試一下是否正常&lt;br /&gt;
進入終端機模式(Terminal)&lt;br /&gt;
輸入&lt;br /&gt;
&lt;pre style=&quot;background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: consolas, &amp;quot;liberation mono&amp;quot;, menlo, courier, monospace; font-size: 13.6px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;&quot;&gt;node -v&lt;/pre&gt;
&lt;div&gt;
是否有出現版本號&lt;/div&gt;
再輸入&lt;br /&gt;
&lt;pre style=&quot;background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: consolas, &amp;quot;liberation mono&amp;quot;, menlo, courier, monospace; font-size: 13.6px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;&quot;&gt;npm -v&lt;/pre&gt;
&lt;div&gt;
是否有出現版本號&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://github.com/milkmidi/front_end_tutorial/blob/master/02_gulp/snapshot/2016-08-14_102309.png?raw=true&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://github.com/milkmidi/front_end_tutorial/blob/master/02_gulp/snapshot/2016-08-14_102309.png?raw=true&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
2. 安裝 gulp&lt;br /&gt;
以下教學參考官方的原文&lt;br /&gt;
&lt;a href=&quot;https://github.com/gulpjs/gulp/blob/master/docs/getting-started.md&quot;&gt;https://github.com/gulpjs/gulp/blob/master/docs/getting-started.md&lt;/a&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13.6px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;&quot;&gt;npm install --global gulp-cli&lt;/pre&gt;
--global 指的是全域應用，也可以縮寫 -g&lt;br /&gt;
&lt;br /&gt;
3. 開啟你的專案資料夾，並啟動 Terminal, 輸入&lt;br /&gt;
&lt;pre style=&quot;background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: consolas, &amp;quot;liberation mono&amp;quot;, menlo, courier, monospace; font-size: 13.6px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;&quot;&gt;npm init&lt;/pre&gt;
之後一直接 entry , entry , entry .....&lt;br /&gt;
就會產生一隻 package.json&lt;br /&gt;
裡面記錄了這個專案會用到的各種套件&lt;br /&gt;
&lt;br /&gt;
4.安裝 gulp 到&amp;nbsp;devDependencies&lt;br /&gt;
&lt;pre style=&quot;background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13.6px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;&quot;&gt;npm install --save-dev gulp&lt;/pre&gt;
--save-dev 可以縮寫成 -s -D&lt;br /&gt;
打開 package.json&lt;br /&gt;
可以看到 devDependencies 多了 gulp : xxx 版本號&lt;br /&gt;
測試一下是否運作正常&lt;br /&gt;
&lt;pre style=&quot;background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13.6px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;&quot;&gt;gulp&lt;/pre&gt;
轉載請註明出處&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/1894412712754935523/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/1894412712754935523' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/1894412712754935523'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/1894412712754935523'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2017/02/2-gulp.html' title='前端攻城屍自動化教學 2 ( gulp 安裝篇)'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-7754438114081228198</id><published>2017-02-01T09:06:00.002+08:00</published><updated>2017-02-05T09:24:01.284+08:00</updated><title type='text'>Adobe Animate cc 廣告素材製作篇</title><content type='html'>&lt;div id=&quot;fullpost&quot;&gt;
大家好，我是奶綠茶&lt;br /&gt;
今天來介紹廣告素材的製作&lt;br /&gt;
使用的是 Adobe Animate CC&lt;br /&gt;
什麼，是新軟體!!!!!&lt;br /&gt;
大家不用怕，其實他的前身是 Adobe Flash&lt;br /&gt;
只是換個名字(去 Flash 化)&lt;br /&gt;
在使用的介面和功能都一模一模&lt;br /&gt;
如果本身就會使用 flash 的朋友一定不莫生&lt;br /&gt;
1. 開啟 Adobe Animate CC&lt;br /&gt;
選擇 HTML5 Canvas 格式&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/03_basicBanner/snapshot/1.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
2.畫一個色塊，並轉成影片片段(MovieClip)元素&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/03_basicBanner/snapshot/2.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. 拉影格拉至 25 ,選擇逼角移動補間動畫&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/03_basicBanner/snapshot/3.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
4.這時可以看到影格間變成淺藍色&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/03_basicBanner/snapshot/4.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. 幫元素取名為 box, 之後才可以用程式控制&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/03_basicBanner/snapshot/5.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
6. 新增一個圖層，取名為 as (筆者的習慣)&lt;br /&gt;
加入程式碼，讓目前的時間軸停止動畫&lt;br /&gt;
this.stop();&lt;br /&gt;
一定要加寫 this 程式碼才會對&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/03_basicBanner/snapshot/6.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. 點擊 box 元素後，播放時間軸動畫, 按下發佈，或是 Ctrol&amp;nbsp;+ Entry , 就可以看到動畫了。&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/03_basicBanner/snapshot/7.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. 有時在交素材時，媒體端不充許外載其他的程式&lt;br /&gt;
因為 Adobe Animate CC HTML5 Canvas 技術是使用一套叫 createjs 的 framework&lt;br /&gt;
他有外部引用他的程式碼&lt;br /&gt;
所以我們要修改一下&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/03_basicBanner/snapshot/8.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
9. 把 createjs 的程式碼載回本機&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/03_basicBanner/snapshot/9.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
10. 跟你的 html, js 放在同一個資料夾下&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/03_basicBanner/snapshot/10.png&quot; /&gt;&lt;br /&gt;
11. 用記事本開啟 .html , 修改引用的路徑，完工&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/03_basicBanner/snapshot/11.png&quot; /&gt;&lt;br /&gt;
祝大家學習愉快&lt;br /&gt;
轉載請註明出處 
&lt;br /&gt;
&lt;a href=&quot;https://github.com/milkmidi/createjs_tutorial/tree/master/03_basicBanner/fla&quot; target=&quot;_blank&quot;&gt;SourceCodeDownload&lt;/a&gt;

&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/7754438114081228198/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/7754438114081228198' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/7754438114081228198'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/7754438114081228198'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2017/02/adobe-animate-cc.html' title='Adobe Animate cc 廣告素材製作篇'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-6947125487362257865</id><published>2016-08-14T10:13:00.003+08:00</published><updated>2016-08-14T10:15:13.223+08:00</updated><title type='text'>前端攻城屍自動化教學 1 (入門軟體篇, 使用 prepros)</title><content type='html'>&lt;div id=&quot;fullpost&quot;&gt;
大家好，我是奶綠茶&lt;br /&gt;
寫程式的最高原則，就是要&quot;懶&quot;&lt;br /&gt;
&quot;懶&quot;指的是 &quot;雜事交由電腦幫你完成&quot;&lt;br /&gt;
你就可以專心在程式面上&lt;br /&gt;
比如說：&lt;br /&gt;
uglifyjs JS 自動幫你把 JS 壓成一行&lt;br /&gt;
自動幫你轉 sass/ scss&lt;br /&gt;
程式碼一存檔，html 就自動 reload&lt;br /&gt;
如果這些事還要手動處理就真的麻煩了&lt;br /&gt;
&lt;br /&gt;
新手可以直接使用現成的軟體&lt;br /&gt;
https://prepros.io/&lt;br /&gt;
這是一套永久免費的軟體(如果覺的好用也支持一下作者)&lt;br /&gt;
免費版和正式版的功能都一樣，差在免費版三不五時會貼心的提醒你要不要付費&lt;br /&gt;
&lt;br /&gt;
1. 下載軟體, 支援 PC(不支援 XP ) 和 Mac&lt;br /&gt;
2. 安裝, 一直下一步下一步下一步&lt;br /&gt;
3. 啟動軟體&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://raw.githubusercontent.com/milkmidi/front_end_tutorial/master/01_prepros/snapshot/2016-08-14_095245.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/front_end_tutorial/master/01_prepros/snapshot/2016-08-14_095245.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
4. 把你的專案資料夾拉進 prepros&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://raw.githubusercontent.com/milkmidi/front_end_tutorial/master/01_prepros/snapshot/2016-08-14_095313.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/front_end_tutorial/master/01_prepros/snapshot/2016-08-14_095313.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
5. 點選你的 js 檔&lt;br /&gt;
可以看到有五個選項&lt;br /&gt;
Auto Compile：當你存檔時是否要自動編譯，當然是要打勾呀。&lt;br /&gt;
SourceMaps：產生 sourcemap 檔，通常會搭配下方的 UglifyJS。&lt;br /&gt;
Uglify JS：幫你把 js 壓縮成一行。&lt;br /&gt;
Convert ES6 to ES5：將 ES6 的語法自動轉成 ES6。&lt;br /&gt;
Mangle Variables：將非全域變數的名字打亂。&lt;br /&gt;
筆者通常都是全勾。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://raw.githubusercontent.com/milkmidi/front_end_tutorial/master/01_prepros/snapshot/2016-08-14_095326.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/front_end_tutorial/master/01_prepros/snapshot/2016-08-14_095326.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. 點選你的 css 檔&lt;br /&gt;
AutoCompile：是否存檔自動編譯&lt;br /&gt;
AutoPrefixCSS：自動加入 css3的 -web-kit 等前綴字。&lt;br /&gt;
SourceMaps：產生 sourceMap檔。&lt;br /&gt;
CompressCSS：將 css 壓縮成一行&lt;br /&gt;
Enable Cssnext：這個我還沒認真研究&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://raw.githubusercontent.com/milkmidi/front_end_tutorial/master/01_prepros/snapshot/2016-08-14_095336.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/front_end_tutorial/master/01_prepros/snapshot/2016-08-14_095336.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
7. 點選你的 html，接下右鍵&lt;br /&gt;
可以看到一個 Live Preview This File&lt;br /&gt;
按下後會啟動一個 localhost 的網頁，之後只要有修改 js, css ，都會自動 reload&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://raw.githubusercontent.com/milkmidi/front_end_tutorial/master/01_prepros/snapshot/2016-08-14_095433.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/front_end_tutorial/master/01_prepros/snapshot/2016-08-14_095433.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
8. 加掛 Proxy&lt;br /&gt;
live reload 預設只能跑 html, 如果想要執行 php 或是 asp.net 的話&lt;br /&gt;
可以在設定裡面開啟 Live Preview Custom Server&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://github.com/milkmidi/front_end_tutorial/blob/master/01_prepros/snapshot/2016-08-14_101036.png?raw=true&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://github.com/milkmidi/front_end_tutorial/blob/master/01_prepros/snapshot/2016-08-14_101036.png?raw=true&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
9. 其他&lt;br /&gt;
Prepros 也整合了 FTP ，可以讓你方便的直接上傳檔案&lt;br /&gt;
&lt;br /&gt;
轉載請註明出處 
&lt;br /&gt;

&lt;a target=&quot;_blank&quot; href=&quot;https://github.com/milkmidi/front_end_tutorial/tree/master/01_prepros&quot; target=&quot;_blank&quot;&gt;SourceCodeDownload&lt;/a&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/6947125487362257865/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/6947125487362257865' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/6947125487362257865'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/6947125487362257865'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2016/08/1-prepros.html' title='前端攻城屍自動化教學 1 (入門軟體篇, 使用 prepros)'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-3567400765435194748</id><published>2016-03-28T11:15:00.003+08:00</published><updated>2016-03-28T17:45:31.886+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><title type='text'>JavaScript Namespae(命名空間)</title><content type='html'>&lt;div id=&quot;fullpost&quot;&gt;
大家好，我是奶綠茶&lt;br /&gt;
今天來討論 JavaScript Namesapce 命名空間&lt;br /&gt;
首先來了解一下 JS 的變數命名原理&lt;br /&gt;
&lt;pre class=&quot;brush: javascript;&quot;&gt;var myVar = &quot;milkmidi&quot;;
// 我是其他的程式碼
// 我是其他的程式碼
// ...
// 我是其他的程式碼
var myVar = 0;
&lt;/pre&gt;
&lt;br /&gt;
可以發現 myVar 被宣告了二次&lt;br /&gt;
而後者變數會蓋掉前則&lt;br /&gt;
function 也是一樣的原理&lt;br /&gt;
&lt;pre class=&quot;brush: javascript;&quot;&gt;function myFun(){
 
}
// 我是其他的程式碼
// 我是其他的程式碼
// ...
// 我是其他的程式碼
function myFun(){ 
 // 蓋掉之前同名的 myFun 函式
}
&lt;/pre&gt;
&lt;br /&gt;
當然自己寫的程式不會發生同變數/函式&lt;br /&gt;
但如果跟其他人一起 Team Work 時，難保別人寫的名稱和你一樣&lt;br /&gt;
為了避免互蓋的問題&lt;br /&gt;
所以我們引用了 Namespace 的方法&lt;br /&gt;
但 JS 並沒有真正的 Namespace&lt;br /&gt;
而且是 Object 來模擬&lt;br /&gt;
&lt;pre class=&quot;brush: javascript;&quot;&gt;// 用 Object 來當 Namespace
// 變數名稱就用自己的英文名來命名
var milkmidi = {};
milkmidi.myVar = &quot;milkmidi&quot;;
milkmidi.myFun = function(){

}
// 我是其他的程式碼
// 我是其他的程式碼
// ...
// 我是其他的程式碼
var otherPartner = {};
otherPartner.myVar = &quot;otherPartner&quot;;
otherPartner.myFun = function(){

}
// 要呼叫自己寫的函式就用 milkmidi.myFun();
// 同事寫的就用 otherPartner.myFun();
&lt;/pre&gt;
&lt;br /&gt;
這樣就可以決解彼此互蓋問題。&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: large;&quot;&gt;決解自己蓋自己的命名空間&lt;/span&gt;&lt;br /&gt;
為了開發方便&lt;br /&gt;
會把自己常用的 JS 依功能來分類&lt;br /&gt;
JS 命名空間也只是用Object變數來模擬，一樣會發生蓋掉的問題&lt;br /&gt;
&lt;pre class=&quot;brush: javascript;&quot;&gt;// script a.js
var milkmidi = {};
milkmidi.getTitle = function(){};

// script b.js
var milkmidi = {};
milkmidi.doFBLogin = function(){};

// script c.js
milkmidi.getTitle();
// 得到會 Error
// 因為 b.js 重新宣告了 var milkmidi = {};
// a.js 裡的變數被蓋掉
&lt;/pre&gt;
&lt;br /&gt;
先了解一下 JS 的變數宣方法&lt;br /&gt;
變數如果是宣告在最外層，以下寫法是相同
&lt;br /&gt;
&lt;pre class=&quot;brush: javascript;&quot;&gt;var milkmidi = {}; // var 的變數會自動跟在 window 下
window.milkmidi = {}; // 直接把變數指定到 window 下
this.milkmidi = {}; // this 指的就是 window
&lt;/pre&gt;
所以在宣告變數前，要先檢查該變數是否存在&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: javascript;&quot;&gt;// 判斷命名空間是否存在
if ( !this.milkmidi ) {
 this.milkmidi = {};
}
// 縮寫，以下寫法相同
this.milkmidi = this.milkmidi || {};
var milkmidi = this.milkmidi || {};
var milkmidi = milkmidi || {};
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: large;&quot;&gt;進階技巧&lt;/span&gt;&lt;br /&gt;
寫程式要盡量封裝&lt;br /&gt;
用不到的變數不要給別人發現&lt;br /&gt;
先了解變數的生命週期是依 function 的宣告&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: javascript;&quot;&gt;


var globalVar = &quot;global&quot;;
function test(){
 var localVar = &quot;local&quot;;
 // 在這可以取得 globalVar
}
// 但在這無法著得 test 裡的 localVar


// 匿名函式的建立與執行
(function(){ 
 // 這裡的程式碼會自動執行一次
})();



(function(){ 
 // 建立私有變數
 var localVar = &quot;milkmidi&quot;;
 // 建立私有函式
 function getLocalVar(){
  return localVar;
 }
 // 這樣寫外部成員完全取不到
})();

// 結合 namespace 
var milkmidi = milkmidi || {};
(function( milkmidi ){
 var localVar = &quot;milkmidi&quot;;
 // 建立私有函式
 function getLocalVar(){
  return localVar;
 }
 // 我想公開 getLocalVar 這個方法
 // 就可以寫
 milkmidi.getLocalVar = getLocalVar;
})( milkmidi );

// 外部成員就可以呼叫
milkmidi.getLocalVar();
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
祝大家學習愉快&lt;br /&gt;
轉載請註明出處 
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/3567400765435194748/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/3567400765435194748' title='1 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/3567400765435194748'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/3567400765435194748'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2016/03/javascript-namespae.html' title='JavaScript Namespae(命名空間)'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-1011227989702326389</id><published>2016-03-07T15:26:00.003+08:00</published><updated>2016-03-07T15:46:44.178+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="html5"/><title type='text'>素材製作好工具 TexturePacker-4.x</title><content type='html'>&lt;div id=&quot;fullpost&quot;&gt;
大家好，我是奶綠茶&lt;br /&gt;
Flash 己經 byebye了&lt;br /&gt;
現在是 HTML5 時代&lt;br /&gt;
為了增加效能與載入速度&lt;br /&gt;
會把用到的素材圖片，壓成一大張&lt;br /&gt;
或是要製作成 SpriteSheet&lt;br /&gt;
現在 TexturePacker 4.x 推出來，來看看有什麼好用的新功能&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7aELztBm5lqmZ7qauJEBsFIO5zzocoIRhKxeqjEQzeFcWrjvx9ZD79YxyyZY0QLPVe15GURkYC8jjGhABXVDxL-0L5dQO3qTdx30JfPPykslIfcLQ9xpLroLydZCht38XhSqVuuKI868/s1600/2016-03-07_152155.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;285&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7aELztBm5lqmZ7qauJEBsFIO5zzocoIRhKxeqjEQzeFcWrjvx9ZD79YxyyZY0QLPVe15GURkYC8jjGhABXVDxL-0L5dQO3qTdx30JfPPykslIfcLQ9xpLroLydZCht38XhSqVuuKI868/s400/2016-03-07_152155.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
把所有的圖片拉進來&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjaqH7S-e8ZLBf8qdeSfE9bqOnrWt654ls7Ui2t_8gp4QsvOYx3whKqAbUYmyQjqd0EiHBhSLR2dkVHeeCkltlBZO8dEnfMLKqkvuIOtZmY8vdd8hWtiJ638GMqec8TU1b2x4ui8T94fQ/s1600/2016-03-07_152304.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;283&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjaqH7S-e8ZLBf8qdeSfE9bqOnrWt654ls7Ui2t_8gp4QsvOYx3whKqAbUYmyQjqd0EiHBhSLR2dkVHeeCkltlBZO8dEnfMLKqkvuIOtZmY8vdd8hWtiJ638GMqec8TU1b2x4ui8T94fQ/s400/2016-03-07_152304.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
奶綠我最常使用的是 CreateJS 和 PixiJS&lt;br /&gt;
選擇要輸出的格式，支援超多的啦&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggbZLD6ka16IPXkM2beBS6OQnTeo706gCySWdQoT8_p15PCzqPl6Pc4pr1WxmaUXQ8TpJ-xs6Gadbvm-BIG_MoX_NJxnzOK7OdsAUObCTP8m8VChGE2AxsEIuuuKI83zKNAiD_1pAILLg/s1600/2016-03-07_152440.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;282&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggbZLD6ka16IPXkM2beBS6OQnTeo706gCySWdQoT8_p15PCzqPl6Pc4pr1WxmaUXQ8TpJ-xs6Gadbvm-BIG_MoX_NJxnzOK7OdsAUObCTP8m8VChGE2AxsEIuuuKI83zKNAiD_1pAILLg/s400/2016-03-07_152440.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
再按下 Publish&lt;br /&gt;
就會匯出你需要的格式，真的很方便&lt;br /&gt;
可以免費的下載使用&lt;br /&gt;
&lt;a href=&quot;https://www.codeandweb.com/texturepacker&quot;&gt;https://www.codeandweb.com/texturepacker&lt;/a&gt;&lt;br /&gt;
免費版會把你的一張圖更改掉，所以也只能用在教學或是測試&lt;br /&gt;
專案要用還是需要付費買一套的喔&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: #f2dede; box-sizing: border-box; color: #a94442; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 700; line-height: 25.7143px; text-align: center;&quot;&gt;TP:B65E3ECD&lt;/span&gt;&lt;br /&gt;
TP:B65E3ECD&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/1011227989702326389/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/1011227989702326389' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/1011227989702326389'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/1011227989702326389'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2016/03/texturepacker-4x.html' title='素材製作好工具 TexturePacker-4.x'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7aELztBm5lqmZ7qauJEBsFIO5zzocoIRhKxeqjEQzeFcWrjvx9ZD79YxyyZY0QLPVe15GURkYC8jjGhABXVDxL-0L5dQO3qTdx30JfPPykslIfcLQ9xpLroLydZCht38XhSqVuuKI868/s72-c/2016-03-07_152155.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-4219708159052972842</id><published>2015-11-17T11:02:00.001+08:00</published><updated>2015-11-17T11:13:51.187+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="html5"/><title type='text'>HTML5 Application cache 離線版網頁</title><content type='html'>&lt;div id=&quot;fullpost&quot;&gt;
大家好，我是奶綠茶&lt;br /&gt;
HTML4 時代，網頁一定要連網才看的到&lt;br /&gt;
但有時在特定的場合，不一定有網路或是網路不穩定就什麼都看不到&lt;br /&gt;
現在 HTML5 提供了一個離線版的技術&lt;br /&gt;
原理就是用 HTML5 Application cache&lt;br /&gt;
事先把需要的檔案存在使用的裝置(PC, iOS, Android)&lt;br /&gt;
W3C的介紹：&lt;a href=&quot;http://www.w3schools.com/html/html5_app_cache.asp&quot; target=&quot;_blank&quot;&gt;http://www.w3schools.com/html/html5_app_cache.asp&lt;/a&gt;&lt;br /&gt;
Application cache 有三個特性&lt;br /&gt;
1. 離線瀏覽(已經快取，直接從裝置載入)&lt;br /&gt;
2. 載入速度快(已經快取，直接從裝置載入)&lt;br /&gt;
3. 漸少伺服器的檔案請求(已經快取，直接從裝置載入)&lt;br /&gt;
(已經快取，直接從裝置載入)，很重要，所以要說三次&lt;br /&gt;
&lt;br /&gt;
以下為程式碼時間&lt;br /&gt;
1. 在你的 html tag 加上 manifest 的屬性，並直定一個 milkmidi.appcache 的文件檔&lt;br /&gt;
&lt;pre class=&quot;brush: as3;&quot;&gt;&amp;lt;html manifest=&quot;milkmidi.appcache&quot;&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
網頁載入時，同時會一起載入 milkmidi.appcache 文件&lt;br /&gt;
該文件就是用來定義那些檔案要被快取&lt;br /&gt;
&lt;br /&gt;
2. Manifest 文件&lt;br /&gt;
新增一個空白的記事本文件，副檔名存成 .appcache 即可&lt;br /&gt;
有三個特別的關鍵字要注意&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: large;&quot;&gt;CACHE MANIFEST&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: as3;&quot;&gt;CACHE MANIFEST
app.css
milkmidi.png
app.js&lt;/pre&gt;
告訴 Browser 要快取住 app.css , milkmidi.png , app.js這三個檔案&lt;br /&gt;
檔案路徑和 html 一樣，因為我的 demo 三個檔都跟 html 放在同一層路徑&lt;br /&gt;
如果你有開資料夾路徑的話，記得也要寫進去&lt;br /&gt;
&lt;br /&gt;
不要快取的檔案
&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: large;&quot;&gt;NETWORK&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: as3;&quot;&gt;NETWORK
login.aspx
&lt;/pre&gt;
&lt;br /&gt;
一般來說，快取都用在存放檔案(css,js,圖片等)&lt;br /&gt;
html 檔因為 K 數小，一般都很少快取&lt;br /&gt;
如果你的展示環境並沒有網路，一定要全都快取的話&lt;br /&gt;
就可以把你的 html 檔也寫進 .appcache 裡&lt;br /&gt;
或是用第三個關鍵字來處理&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: large;&quot;&gt;FALLBACK&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: as3;&quot;&gt;FALLBACK
offline.html
&lt;/pre&gt;
有網路時，就會連你的 index.html&lt;br /&gt;
離線時，就載入 offline.html&lt;br /&gt;
&lt;br /&gt;
3. 更新檔案&lt;br /&gt;
只要你的 appcache 有更動，Browser 就會自動重新載入 appcache 裡要快取的檔&lt;br /&gt;
這時可以用寫注解的方法&lt;br /&gt;
# 表示注解&lt;br /&gt;
&lt;pre class=&quot;brush: as3;&quot;&gt;CACHE MANIFEST
# 2015-11-7 v1.0.0
app.css
milkmidi.png.gif
app.js

NETWORK:
login.aspx

FALLBACK:
offline.html
&lt;/pre&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.milkmidi.com/demo/201511_html5_application_cache/&quot; target=&quot;_blank&quot;&gt;線上Demo&lt;/a&gt;&lt;br /&gt;
轉載請註明出處 
&lt;br /&gt;
&lt;a href=&quot;http://www.milkmidi.com/demo/201511_html5_application_cache/201511_html5_application_cache.zip&quot;&gt;SourceCodeDownload&lt;/a&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/4219708159052972842/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/4219708159052972842' title='2 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/4219708159052972842'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/4219708159052972842'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2015/11/html5-application-cache.html' title='HTML5 Application cache 離線版網頁'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-5086590646920361961</id><published>2015-04-07T22:05:00.002+08:00</published><updated>2015-04-07T22:07:22.900+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="createJS"/><title type='text'>CreateJS系列教學-第二篇 樂透轉轉機</title><content type='html'>&lt;div id=&quot;fullpost&quot;&gt;
大家好，我是奶綠茶&lt;br /&gt;
熟悉了 Adobe Flash CC2014 匯出成 html5 CreateJS 教學後&lt;br /&gt;
接著我們再來練習把 JS 的程式碼寫成 Flash CC2014 裡&lt;br /&gt;
直接匯出成 html5 格式，製作速度之快，是其他軟體比不上的呀。&lt;br /&gt;
請到老師的好友, Titan 老師, 把之前製作過的 Flash 樂透轉轉機&lt;br /&gt;
轉成 html5 格式，讓桌機和手機同時支援&lt;br /&gt;
&lt;br /&gt;
用 Flash CC2014 開啟之前製作好的 fla 檔&lt;br /&gt;
原本是 AS 文件，要轉存成 html5 文件&lt;br /&gt;
選擇上方工具列：命令 / 從 AS3 文件格式轉換為 HTML5 Canvas&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1kBNs6fMAcUr11IRP-5PZhxFSQ_5FxiLxNExeWMTogYhZPwHYRv7QGKn1RzH96p-t4cduT8QnxhYwQ5va1rg1-75MIXW_H1zWgHEVKO0GKMx-Cb1IUxSJ6Fh8h9VHOrztvgPyiQKq6rk/s1600/01.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
存好新檔後，可以看到屬性面試顯示為 HTML5 Canvas 文件&lt;br /&gt;
此時在時間軸寫的程式碼是 JS 而不是 AS 喔&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOwppWp7gWCUCF-f78vrIFlLHe_2ki3V0rb5wZjqL63QGKikfLkodFch0QkTjFnFEMCFCSt85HwuFrbHj66J_csK3BukW6GlXrDI5fVIoxABj1hGXzsMpllrbQ28NZQpRC9YerfJ4C0cg/s1600/02.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
在這個範列下，需要再增加二段 JS 程式碼&lt;br /&gt;
1. 在影格 1 加入點擊後開始播放&lt;br /&gt;
&lt;pre class=&quot;brush: as3;&quot;&gt;
this.stop();
// 方法1, &amp;nbsp;用 on 的方法偵聽事件
this.on(&quot;click&quot;,function(){
// 用 on 的方法，此時 this 指向會是自己
console.log(&quot;on&quot;,this);
this.gotoAndPlay(1);

});


// 方法2，用 addEventListener 方法偵聽事件
this.addEventListener(&quot;click&quot;,function(){
// 用 addEventLister 方法， this 指向會指到 Window
console.log( &quot;addEventListener&quot;,this );

});



&lt;/pre&gt;
二者的差別在 this 的 scope 指向，奶老師個人編好使用 on 的方法來偵聽&lt;br /&gt;
因為只要打二個字(整個就是懶)。&lt;br /&gt;
提醒一下，在本機開發時 Chrome 會檔掉 click 事件，跳出這樣的訊件&lt;br /&gt;
Uncaught An error has occurred. This is most likely due to security restrictions on reading canvas pixel data with local or cross-domain images.&lt;br /&gt;
因為我們引用的 js 是來自 code.createjs.com 。&lt;br /&gt;
決解辦法就是丟到網路上即可，或是改用 Firefox 即可本機開發。&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhH3awT0xIe1ec3zSdDCSQlQbeSfFAKHAnov8T5uScH1p4tmUj7fLnPvB1R2Av3G27hzey6N5Bt_Wn4lv9-M8TxwG1LWjpWW2R35FvlKfwPh1QJTvXdnsn7jCR89PJTsw0fLp_1eaJMPlk/s1600/05.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. 轉轉機的結果&lt;br /&gt;
我們把要顯示的文字元件放在 txt_mc 元件裡，該元件放了三個影格。&lt;br /&gt;
只要加上亂數跳到指定的影格即可&lt;br /&gt;
var frame = Math.floor( Math.random() * 2 + 0.5);&lt;br /&gt;
this.txt_mc.gotoAndStop(frame);&lt;br /&gt;
this.play();&lt;br /&gt;
HTML5 文件下，影格是從 0 開始喔。&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizZPRfOa7k1mgtjXYaCS_1gMJ6sIdQTujg5nWyJ1eNaqL2kkTFOxyRiFETIKS7soDhZes2lqkgQVbS0E2jArY_8XHSGNQiOlHRmeHulJmQldh9qNQoAt7sS1uOTXNUoWheV9DUFzZoykc/s1600/06.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
製作動畫的方式就和以往一樣，沒有任何改變，不需要再另外重新學習&lt;br /&gt;
有些小地方還是要提醒一下，並不是所有的功能都支援轉換&lt;br /&gt;
1. 本來在 AS 格式寫的程式碼，轉換為 HTML5 格式後，會自動被注解&lt;br /&gt;
FlashCC2014 只轉換動畫部份，程式還是需要重寫為 JS 格式。&lt;br /&gt;
2. 不支援 Filter 和混色模式。&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGa0_EqM7x1kq3YhICi8rNMjeBaGXraOu9g4zRH7PTDQkLAjFprUCyLDwjS1xyYejzrw5ba3Aq8F8PC6-Uk3moGyVFrNmVr2Dbi2HGJtqUNUciD-yFulsah-a_X6OeA9zQaleZZH8hUbU/s1600/03.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
3.顏色效果只支援 Alpha 。&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyi7-f_kri2fpm6WYOe_H7ZBOj8x_XIChECdJIUocdRQ49cez5-PKyUAb0qSujpCOmqFJYCIHr-wqtFFrs4fWjLrwxdmrhHMW3xhO8x4K5DOhoSn9ii-h0EUGfTOCWHvlSo1r7KTWeyLE/s1600/04.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. 時間軸影格是從 0 開始(AS格式是從 1 開始)&lt;br /&gt;
EaselJS 中的影格編號從 0 開始，而非 1。例如，這會影響 gotoAndStop 和 gotoAndPlay 呼叫。&lt;br /&gt;
&lt;br /&gt;
線上Demo&lt;br /&gt;
&lt;a href=&quot;http://www.milkmidi.com/demo/201504_flashcc_createjs_part2/&quot; target=&quot;_blank&quot;&gt;http://www.milkmidi.com/demo/201504_flashcc_createjs_part2/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
祝大家學習愉快。&lt;br /&gt;
完整的 Source 下載&lt;br /&gt;
&lt;a href=&quot;https://github.com/milkmidi/createjs_tutorial/tree/master/02_capsuleToy&quot; target=&quot;_blank&quot;&gt;https://github.com/milkmidi/createjs_tutorial/tree/master/02_capsuleToy&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
轉載請註明出處 
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/5086590646920361961/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/5086590646920361961' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/5086590646920361961'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/5086590646920361961'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2015/04/createjs.html' title='CreateJS系列教學-第二篇 樂透轉轉機'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1kBNs6fMAcUr11IRP-5PZhxFSQ_5FxiLxNExeWMTogYhZPwHYRv7QGKn1RzH96p-t4cduT8QnxhYwQ5va1rg1-75MIXW_H1zWgHEVKO0GKMx-Cb1IUxSJ6Fh8h9VHOrztvgPyiQKq6rk/s72-c/01.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-5448888262542690049</id><published>2014-12-26T11:40:00.002+08:00</published><updated>2014-12-26T11:42:22.609+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="adobe"/><category scheme="http://www.blogger.com/atom/ns#" term="createJS"/><category scheme="http://www.blogger.com/atom/ns#" term="html5"/><title type='text'>CreateJS系列教學-第一篇 AdobeCC2014 Export</title><content type='html'>&lt;div id=&quot;fullpost&quot;&gt;
大家好，我是奶綠茶&lt;br /&gt;
Adobe今年推出了 CC2014 系列工具，&lt;br /&gt;
身為 &quot;阿豆比米&quot; 是一定要來研究一下有什麼新功能。&lt;br /&gt;
就從最熟悉的 FlashCC2014 來介紹起&lt;br /&gt;
很多學生問我該不該再學 Flash&lt;br /&gt;
因為行動裝置上不能執行 Flash , 且 HTML5 的普及，Flash 的黃金時代已過去，&lt;br /&gt;
但這不表示 Flash 工具就從此退役喔。&lt;br /&gt;
對設計師來說，Flash還是世上最好用的動畫工具，&lt;br /&gt;
今天就來介紹如何使用 Adobe FlashCC2014,&lt;br /&gt;
將 Flash 裡的時間軸動畫輸出成 HTML5 的格式，這樣就能同時支援桌機與行動裝置平台。&lt;br /&gt;
&lt;br /&gt;
軟體啟動可以看到新的啟動畫面，這也是每次有新版本推出時&lt;br /&gt;
筆者最期待的功能之一。&lt;br /&gt;
&lt;img border=&quot;0&quot; br=&quot;&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/01_flashCCExport/snapshot/1.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
延續 Adobe Flash CC, 使用介面可以調整成暗色系&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/01_flashCCExport/snapshot/2.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
接著我們新增檔案，選擇 HTML5 Canvas 格式&lt;br /&gt;
AdobeCC20014 支援了 WebGL 的輸出，這個等下一篇再來介紹。&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/01_flashCCExport/snapshot/3.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
在屬性面版可以看到是 HTML5 Canvas 文件&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/01_flashCCExport/snapshot/4.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
如果想把舊有的 AS fla 轉成 HTML5 Canvas fla文件的話&lt;br /&gt;
只要執行上方工具列 / 命令 / 從 AS3 文件格式轉換為 HTML5 Canvas 即可&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/01_flashCCExport/snapshot/11.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
將舞台大小設定為 640 x 400&lt;br /&gt;
寬度 640 是因為當 Mobile Web viewport 設定成 width=device-width 時&lt;br /&gt;
大多數的裝置的寬度會得到 320, 因應 Retina 顯示, 所以要 320 乘 2 = 640。&lt;br /&gt;
接著我們拉個簡單的動畫, 讓圖示由左到右，再到下，再到左，再回來本來的位置&lt;br /&gt;
做一個口字型的移動。&lt;br /&gt;
時間軸長這樣&lt;br /&gt;
&lt;img border=&quot;0&quot; height=&quot;57&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/01_flashCCExport/snapshot/5.png&quot; width=&quot;640&quot; /&gt;

&lt;br /&gt;
&lt;br /&gt;
在第一格影格寫上程式碼&lt;br /&gt;
要注意喔，因為是 HTML5 Canvas 文件&lt;br /&gt;
所以是寫 JavaScript, 而不是 ActioinScript&lt;br /&gt;
完整的 CreateJS JavaScript 提示，這對初學者有很大的幫助&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/01_flashCCExport/snapshot/6.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
分邊在指定的影格下 this.stop();&lt;br /&gt;
讓動畫播到此處時暫停，然後點擊後再播放&lt;br /&gt;
為了能讓任意處點擊都有效，所以在下方放置一個白色(或透明)的色塊&lt;br /&gt;
&lt;img border=&quot;0&quot; height=&quot;272&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/01_flashCCExport/snapshot/7.png&quot; width=&quot;640&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
在第一個影格寫上點擊事件&lt;br /&gt;
要注意一下，因為是 JavaScript，所以會有 scope 的問題&lt;br /&gt;
如果只寫 stop(); JS 不會知道是要執行誰的 stop();&lt;br /&gt;
所以要加上 this&lt;br /&gt;
偵聽事件就跟 AS3 寫法一樣。&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/01_flashCCExport/snapshot/8.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
測試過程中 Chrome 因為本機安全性的關系, 在點擊時會發生&lt;br /&gt;
&amp;nbsp;Uncaught An error has occurred. This is most likely due to security restrictions on reading canvas pixel data with local or cross-domain images.&lt;br /&gt;
這個錯誤，決解的方法就是丟到 http 下測試，或是改用 Firefix 即可決解。&lt;br /&gt;
&lt;br /&gt;
接著就可以發佈檔案&lt;br /&gt;
fla就是 Flash 的原始碼&lt;br /&gt;
images 裡的資料夾, 就是 fla 裡有用到的圖片&lt;br /&gt;
可以用筆事本打開 html, js, 發現是很好閱讀的程式碼喔&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/01_flashCCExport/snapshot/12.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
修正程式碼，讓 createJS 能夠自動滿版&lt;br /&gt;
打開 .html , 新增以下程式碼，就完成了。&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/createjs_tutorial/master/01_flashCCExport/snapshot/10.png&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
筆者將完整的 demo 檔放在 github 上&lt;br /&gt;
&lt;a href=&quot;https://github.com/milkmidi/createjs_tutorial&quot; target=&quot;_blank&quot;&gt;https://github.com/milkmidi/createjs_tutorial&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
謝謝大家&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/5448888262542690049/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/5448888262542690049' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/5448888262542690049'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/5448888262542690049'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2014/12/createjs-adobecc2014-export.html' title='CreateJS系列教學-第一篇 AdobeCC2014 Export'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-428586189809868687</id><published>2014-12-19T15:37:00.001+08:00</published><updated>2014-12-19T17:31:51.043+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><title type='text'>Android View y,translationY 比較</title><content type='html'>&lt;div id=&quot;fullpost&quot;&gt;
大家好，我是奶綠茶&lt;br /&gt;
Android View 物件有 setY 和 setTranslationY 二個屬性&lt;br /&gt;
都是可以更改 y軸座標，兩個屬性原理有些不一樣&lt;br /&gt;
setY(10) ：以父容器為基準，設置 y 軸座標為 10&lt;br /&gt;
View.setY Source 如下&lt;br /&gt;
public void setY(float y) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; setTranslationY(y - mTop);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
setTranslationY(10)：自己為基準，設置 y 軸座標為 10&lt;br /&gt;
測試結果如下圖&lt;br /&gt;
紅底圖為測試的 ImageView，layout_below 綠底文字&lt;br /&gt;
上層有個淡紅色的 RelativeLayout 父容器&lt;br /&gt;
呼叫 getY() 時，因為經過 RelativeLayout 排版&lt;br /&gt;
以父容器為基準值，得到 &amp;nbsp;109&lt;br /&gt;
getTranslationY() 以自己為準基，所以值為 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0h_m6ESCZL-2QbrWFyIGNixeroKgbx1UDWf2IYhxkEYZZJzW6Lm1zXWy9zwJaYQQ0Apxr26hwPO4CMZax2GajjzeUEkcBAvGrDrQPrvZ6xb6vFCWyN7-Ph7XKfyuVYRZm1p1ZRAA2rlU/s1600/1.jpg&quot; /&gt;
&lt;br /&gt;
轉載請註明出處&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/428586189809868687/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/428586189809868687' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/428586189809868687'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/428586189809868687'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2014/12/android-view-ytranslationy.html' title='Android View y,translationY 比較'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0h_m6ESCZL-2QbrWFyIGNixeroKgbx1UDWf2IYhxkEYZZJzW6Lm1zXWy9zwJaYQQ0Apxr26hwPO4CMZax2GajjzeUEkcBAvGrDrQPrvZ6xb6vFCWyN7-Ph7XKfyuVYRZm1p1ZRAA2rlU/s72-c/1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-246811802121512497</id><published>2014-11-04T10:41:00.002+08:00</published><updated>2014-11-04T10:41:39.708+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><title type='text'>android Drawselectorontop</title><content type='html'>&lt;div id=&quot;fullpost&quot;&gt;
大家好，我是奶綠茶&lt;br /&gt;
在使用 ListView 時有個 drawselectonTop 的屬性能夠使用&lt;br /&gt;
原文：&lt;br /&gt;
Controls whether the selection highlight drawable should be drawn on top of the item or behind it.&lt;br /&gt;
意思是說選取時是否要繪制在物件上&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2in7Iamy7Nyssd8rQF0Lem4h6w-NJTXMP5lx5fxhUztyLIC5Ii9ivT9CqMtekoyoH3NjbK9KJmmsmJ03DiwWNjAR-tfMIbN2ijDgQmsBut-yiCWiK1EU5N57Zr3pgroha8SHQLkWg7lA/s1600/1.png&quot; /&gt;
&lt;br /&gt;
左圖是一般樣式，右圖是指定 drawselectonTop ，這樣選取時就會有 highlight的效果&lt;br /&gt;
&lt;br /&gt;
一般的 ViewGroup 並沒有這樣的功能&lt;br /&gt;
謙裡有現成的Library可以使用，祝大家學習愉快。&lt;br /&gt;
轉載請註明出處 
&lt;br /&gt;
&lt;a href=&quot;https://gist.github.com/chrisbanes/9091754&quot;&gt;https://gist.github.com/chrisbanes/9091754&lt;/a&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/246811802121512497/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/246811802121512497' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/246811802121512497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/246811802121512497'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2014/11/android-drawselectorontop.html' title='android Drawselectorontop'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2in7Iamy7Nyssd8rQF0Lem4h6w-NJTXMP5lx5fxhUztyLIC5Ii9ivT9CqMtekoyoH3NjbK9KJmmsmJ03DiwWNjAR-tfMIbN2ijDgQmsBut-yiCWiK1EU5N57Zr3pgroha8SHQLkWg7lA/s72-c/1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-6788533344678908690</id><published>2014-04-16T09:53:00.001+08:00</published><updated>2014-04-16T10:56:00.451+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Flash"/><title type='text'>Flash Timeline to TweenMaxJS</title><content type='html'>&lt;div id=&quot;fullpost&quot;&gt;
大家好，我是奶綠茶&lt;br /&gt;
因為專案的需求&lt;br /&gt;
現在客戶都要製作 html 的網頁&lt;br /&gt;
但在製作動態效果上就有些麻煩&lt;br /&gt;
都只能用 js 寫出來&lt;br /&gt;
使用 createJS 轉出來是 HTML5 Canvas 版本&lt;br /&gt;
快樂 &amp;nbsp;IE8 不支援&lt;br /&gt;
所以筆者寫了一個 Flash 的小外掛&lt;br /&gt;
能將 Flash 裡的時間軸動畫輸出成 html 的程式碼&lt;br /&gt;
動態的部份是使用 TweenMax 來製作&lt;br /&gt;
這樣就可以用熟悉的工具拉時間軸動畫&lt;br /&gt;
且支援舊的 Browser&lt;br /&gt;
不是所有的 Flash 裡的效果都有支援轉換&lt;br /&gt;
一定要本來 html 做的到的功能才行&lt;br /&gt;
感謝老婆大大 Betty 提供的idea(聽老婆的話就對了,羞)&lt;br /&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 15px; line-height: 25.5px; margin-bottom: 15px; margin-top: 15px;&quot;&gt;
Adobe Flash CS6 Timeline to TweenMaxJS&amp;nbsp;&lt;a href=&quot;https://raw.githubusercontent.com/milkmidi/flashtimeline_to_tweenmaxjs/master/img.jpg&quot; style=&quot;box-sizing: border-box; color: #4183c4; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;img alt=&quot;alt tag&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/flashtimeline_to_tweenmaxjs/master/img.jpg&quot; style=&quot;border: 0px; box-sizing: border-box; max-width: 100%;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h3 style=&quot;box-sizing: border-box; color: #333333; cursor: text; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 1.5em; line-height: 1.7; margin: 1em 0px 15px; padding: 0px; position: relative;&quot;&gt;
&lt;a class=&quot;anchor&quot; href=&quot;https://github.com/milkmidi/flashtimeline_to_tweenmaxjs#%E5%B0%87%E7%9B%AE%E5%89%8D%E7%9A%84%E6%99%82%E9%96%93%E8%BB%B8%E8%BD%89%E6%88%90-tweenmax-js-%E7%89%88%E7%A8%8B%E5%BC%8F%E7%A2%BC&quot; name=&quot;user-content-%E5%B0%87%E7%9B%AE%E5%89%8D%E7%9A%84%E6%99%82%E9%96%93%E8%BB%B8%E8%BD%89%E6%88%90-tweenmax-js-%E7%89%88%E7%A8%8B%E5%BC%8F%E7%A2%BC&quot; style=&quot;bottom: 0px; box-sizing: border-box; color: #4183c4; cursor: pointer; display: block; left: 0px; margin-left: -30px; padding-left: 30px; padding-right: 6px; position: absolute; text-decoration: none; top: 0px;&quot;&gt;&lt;/a&gt;將目前的時間軸轉成 TweenMax JS 版程式碼&lt;/h3&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 15px; line-height: 25.5px; margin-bottom: 15px; margin-top: 15px;&quot;&gt;
使用方法：&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;1. 下載&amp;nbsp;&lt;a href=&quot;https://github.com/milkmidi/flashtimeline_to_tweenmaxjs/blob/master/flashTimelineToTweenMaxJS.zxp&quot; style=&quot;box-sizing: border-box; color: #4183c4; text-decoration: none;&quot;&gt;flashTimelineToTweenMaxJS.zxp&lt;/a&gt;&amp;nbsp;2. 開啟 FlashCS6(FlashCC).&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;3. 在 PC 上，中文 OS 安裝英文版 Flash 軟體時, 安裝 extensions 會有語系問題&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;解決方法是從 Flash / Help / Manage Extensions 啟動並安裝&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;&lt;a href=&quot;https://raw.githubusercontent.com/milkmidi/flashtimeline_to_tweenmaxjs/master/manageExtensions.png&quot; style=&quot;box-sizing: border-box; color: #4183c4; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;img alt=&quot;alt tag&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/flashtimeline_to_tweenmaxjs/master/manageExtensions.png&quot; style=&quot;border: 0px; box-sizing: border-box; max-width: 100%;&quot; /&gt;&lt;/a&gt;&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;4. 製作你的時間軸動畫或&lt;a href=&quot;https://github.com/milkmidi/flashtimeline_to_tweenmaxjs/blob/master/demo.fla&quot; style=&quot;box-sizing: border-box; color: #4183c4; text-decoration: none;&quot;&gt;點我下載 Demo.fla&lt;/a&gt;&amp;nbsp;.&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;5. 第一個影格不能是空.&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;&lt;a href=&quot;https://raw.githubusercontent.com/milkmidi/flashtimeline_to_tweenmaxjs/master/keyframe.png&quot; style=&quot;box-sizing: border-box; color: #4183c4; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;img alt=&quot;alt tag&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/flashtimeline_to_tweenmaxjs/master/keyframe.png&quot; style=&quot;border: 0px; box-sizing: border-box; max-width: 100%;&quot; /&gt;&lt;/a&gt;&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;6. 點擊上方工具列 / 命令 / flashTimelineToTweenMaxJS&amp;nbsp;&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;&lt;a href=&quot;https://raw.githubusercontent.com/milkmidi/flashtimeline_to_tweenmaxjs/master/command.png&quot; style=&quot;box-sizing: border-box; color: #4183c4; outline: 0px;&quot; target=&quot;_blank&quot;&gt;&lt;img alt=&quot;alt tag&quot; src=&quot;https://raw.githubusercontent.com/milkmidi/flashtimeline_to_tweenmaxjs/master/command.png&quot; style=&quot;border: 0px; box-sizing: border-box; max-width: 100%;&quot; /&gt;&lt;/a&gt;&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;7. 在同 fla 資料夾下即可看到匯出的 html 檔.&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;8. html 需要引用 TweenMax 和 jQuery 的 Library.&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;createJS 轉出來的是 html5 canvas 動畫, 快樂 IE8 不支援&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;我的小工具只是將動畫轉成 TweenMax 的程式碼，省去前端攻城屍 Coding 時間&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 15px; line-height: 25.5px; margin-bottom: 15px; margin-top: 15px;&quot;&gt;
zxp_source 資料夾裡是完整的 Source Code&amp;nbsp;&lt;/div&gt;
&lt;br /&gt;
完整的 SourceCode 我放在 Github 上&lt;br /&gt;
&lt;a href=&quot;https://github.com/milkmidi/flashtimeline_to_tweenmaxjs&quot; target=&quot;_blank&quot;&gt;https://github.com/milkmidi/flashtimeline_to_tweenmaxjs&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
轉載請註明出處&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/6788533344678908690/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/6788533344678908690' title='3 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/6788533344678908690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/6788533344678908690'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2014/04/flash-timeline-to-tweenmaxjs.html' title='Flash Timeline to TweenMaxJS'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-6260668919572168963</id><published>2014-04-15T13:50:00.000+08:00</published><updated>2014-04-15T13:52:13.136+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="開發人員小工具"/><title type='text'>壓縮你的js程式碼</title><content type='html'>&lt;div id=&quot;fullpost&quot;&gt;
大家好，我是奶綠茶&lt;br /&gt;
在專案上線前，我都會把 js 的程式碼壓縮成最小化&lt;br /&gt;
一來 k 數小，二來也比較安全一點&lt;br /&gt;
我是使用 Google 的線上壓縮JS服務&lt;br /&gt;
&lt;a href=&quot;http://closure-compiler.appspot.com/home&quot;&gt;http://closure-compiler.appspot.com/home&lt;/a&gt;&lt;br /&gt;
但每次都要線上壓有點麻煩&lt;br /&gt;
好在他有提供 api 和 jar 可以使用&lt;br /&gt;
寫一個簡單的 bat 檔，把你的本來的 js 檔接過去執行&lt;br /&gt;
就會自動幫你另存一個壓過後的 js 版本&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: as3;&quot;&gt;:: @echo off
:: 指定你的 jar 路徑
set COMPILER=&quot;F:\[Service]\google-closure\compiler.jar&quot;

@echo &quot;%~f1&quot;

SET v_filename=%~nx1
SET v_ext=%~x1
SET v_remainder=%~dp1
java -jar %COMPILER% --js &quot;%~f1&quot; --js_output_file %v_filename%.min.js


pause
&lt;/pre&gt;
&lt;br /&gt;
如果你是使用 vs 系列的開發人員&lt;br /&gt;
可以加裝這一套外掛&lt;br /&gt;&lt;a href=&quot;http://visualstudiogallery.msdn.microsoft.com/07d54d12-7133-4e15-becb-6f451ea3bea6&quot;&gt;http://visualstudiogallery.msdn.microsoft.com/07d54d12-7133-4e15-becb-6f451ea3bea6&lt;/a&gt;&lt;br /&gt;
將你寫好的 js 檔，同路徑下另存一個 xxxx.min.js&lt;br /&gt;
只要按存檔, 就會自動幫你壓縮好&lt;br /&gt;
超方便的&lt;br /&gt;
大推&lt;br /&gt;
&lt;br /&gt;
轉載請註明出處&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/6260668919572168963/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/6260668919572168963' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/6260668919572168963'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/6260668919572168963'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2014/04/js.html' title='壓縮你的js程式碼'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-1379769929044160360</id><published>2014-02-18T11:08:00.002+08:00</published><updated>2014-02-18T11:08:42.281+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="unity3d"/><title type='text'>unity Android Back鍵</title><content type='html'>&lt;div id=&quot;fullpost&quot;&gt;
在 unity 裡，想要得到 Android 接下 Back 鍵事件
可以用以下方法
&lt;br /&gt;
&lt;br /&gt;
轉載請註明出處 
&lt;br /&gt;
&lt;pre class=&quot;brush: csharp;&quot;&gt;
if (Application.platform == RuntimePlatform.Android) {
 if ( Input.GetKeyDown( KeyCode.Escape )  ) {
  Application.Quit();//離開應用程式
 }
}
&lt;/pre&gt;

&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/1379769929044160360/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/1379769929044160360' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/1379769929044160360'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/1379769929044160360'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2014/02/unity-android-back.html' title='unity Android Back鍵'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-5997936926998244315</id><published>2014-02-17T10:34:00.001+08:00</published><updated>2014-02-17T10:35:10.797+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="unity3d"/><title type='text'>unity setTimeout (C#)</title><content type='html'>&lt;div id=&quot;fullpost&quot;&gt;
在 unity C#沒有 setTimeout 這個函式&lt;br /&gt;
但可以用以下方法實作&lt;br /&gt;

&lt;br /&gt;
轉載請註明出處 
&lt;br /&gt;
&lt;pre class=&quot;brush: csharp;&quot;&gt;
 public IEnumerator doSomethingWaitFor() {
        yield return new WaitForSeconds( 2.0f );
        Debug.Log( &quot;doSomethingWaitFor&quot; );
        我要執行的函式();
}
void 我要執行的函式(){
       Debug.Log( &quot;我要執行的函式&quot; );
}
&lt;/pre&gt;

&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/5997936926998244315/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/5997936926998244315' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/5997936926998244315'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/5997936926998244315'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2014/02/unity-settimeout-c.html' title='unity setTimeout (C#)'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-594916360071908907</id><published>2014-02-13T12:00:00.003+08:00</published><updated>2014-02-13T12:00:49.441+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="unity3d"/><title type='text'>unity 練習之 FlappyBird 遊戲設計</title><content type='html'>&lt;div id=&quot;fullpost&quot;&gt;
大家好，我是奶綠茶&lt;br /&gt;
花了一些時間用 unity 提供的 2D功能練習寫 FlappyBird&lt;br /&gt;
&lt;a href=&quot;http://www.milkmidi.com/demo/2014_02_unity_flappybird/web.html&quot; target=&quot;_blank&quot;&gt;http://www.milkmidi.com/demo/2014_02_unity_flappybird/web.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
版權所有屬於原作者，以上純屬技術練習，並無商業營利行為!&lt;br /&gt;
有空再來分享製作心得&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/594916360071908907/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/594916360071908907' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/594916360071908907'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/594916360071908907'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2014/02/unity-flappybird.html' title='unity 練習之 FlappyBird 遊戲設計'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2389124153774442796.post-3689227197185975191</id><published>2014-01-23T11:37:00.000+08:00</published><updated>2014-01-23T11:40:37.143+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><title type='text'>Android完全入門篇-01 安裝SDK與裝置USBDriver</title><content type='html'>&lt;div id=&quot;fullpost&quot;&gt;
大家好，我是奶綠茶&lt;br /&gt;
筆者以 Windows 系統來介紹安裝&lt;br /&gt;
1. 下載 Android SDK&lt;br /&gt;
&lt;a href=&quot;http://developer.android.com/sdk/index.html&quot; target=&quot;_blank&quot;&gt;http://developer.android.com/sdk/index.html&lt;/a&gt;&lt;br /&gt;
有分 32 位元和 64 位元的版本&lt;br /&gt;
為了教學方便，筆者將檔案放置在 D:\ 下&lt;br /&gt;
壓開後會有&lt;br /&gt;
eclipse資料夾：Eclipse程式碼編譯器&lt;br /&gt;
sdk：Android 開發用的 SDK&lt;br /&gt;
SDK Manager.exe：sdk管理用的軟體&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhME1YuTc0L9ZVAKozMolxItZggmZOCabkzgaHExUoAr1l73vYwEj_4YPy9FUh2VY3afeCs3XdpTpjhkktYHekue8rUr5tqESE_5sLcEpHVIAlVwU0WgchhLUjNnPQQ3gSp-KMqj6MzBms/s1600/2014-01-23_110231.png&quot; height=&quot;259&quot; width=&quot;640&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. 開啟手機的&quot;&lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;開發人員選項&lt;/b&gt;&lt;/span&gt;&quot;&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEha4nCHdc7tig05eqvHwQ9BzkzQdUWsRZt7jPCtxgRKRrLle-Bs8bLYDe6KYur7NUF08kcrz2yKr41gdkj_lAyTKvzBze75H_79OPJ1y0q-VW0v9vcnPA-hIWRV2yeV-o2C0ADnKZ45H5I/s1600/1.png&quot; height=&quot;400&quot; width=&quot;242&quot; /&gt;
部份手機該選項被隱藏起來了&lt;br /&gt;
要開啟的話，點選&quot;&lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;關於手機&lt;/b&gt;&lt;/span&gt;&quot;&lt;br /&gt;
接著連點&quot;&lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;版本號碼&lt;/b&gt;&lt;/span&gt;&quot;七次，就會重新開啟該功能&lt;br /&gt;
接著再開啟&quot;USB偵錯&quot;功能&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUCU7P5aD3uF70_YzUixOVYGQHKcDOWcAkIKaPyxHYu0kvlm3T5gIUR2pCmfm8m99aEIiMaPLQMwwMpR9cdrbF6a0BM39ho0Y-7za2tshlT5Lss5uwHVi6UYz0ieWzEuLxNv5Q449MY94/s1600/2.png&quot; height=&quot;400&quot; width=&quot;242&quot; /&gt;
接上你的 USB 線後&lt;br /&gt;
這樣你的電腦才能透過 USB 線來偵錯手機的資訊&lt;br /&gt;
3. 為裝置安裝 adb usb driver&lt;br /&gt;
因為各家廠牌的 Driver 都不同也不通用，所以需要自行 Google 找 Driver&lt;br /&gt;
可以用&quot;XXX廠牌 型號 adb usb driver&quot;關鍵字來找&lt;br /&gt;
例：&lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;HTC Newone adb usb driver&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
接著找到 我的電腦 / 內容&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzB2VMciUmEykP1pejMY7ycIS2owdMnusUqo8XG8zyCrr_4sMqjq0srOU4f3QrqqD5vN_z4tFTslA70dkWK7g0FJYgXpOt3-iWTdjxIz_UZVfT_tHIo00qYh3kZm7cWZ_Qax6FClR52SQ/s1600/2014-01-23_103745.png&quot; height=&quot;340&quot; width=&quot;400&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
裝置管理員&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxfyeUM7c7OUzMnoRqEr7S1B-z5iOeoMdJtH9MHieaZiOiFnTkqHrwSx6FzFFzgHr-7eLkbamGVh6hqI09U6l69f45Ji4HfQxUu00FtmhUa0xGm4FgvgXVPxwLMqeuJxm0SUCt44SygNU/s1600/2014-01-23_103823.png&quot; height=&quot;330&quot; width=&quot;400&quot; /&gt;
&lt;br /&gt;
會看到一個金嘆號未知的裝置, 按右鍵&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;更新驅動程式軟體&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPgodXE2uUZi3k4xjuI4VHr9qdIrUTnqteQxxe6T0B4zCRbpMCB6ipnlsbeoi52bTRnLNNvk51nIwwGRvufZ0NMJOrua_ELvjdJFj0qFxEA_BRwAkY_hNVNfZwHPQXM9HW4FXWRyDf4cc/s1600/2014-01-23_104509.png&quot; height=&quot;291&quot; width=&quot;400&quot; /&gt;
&lt;br /&gt;
選擇&quot;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;瀏覽電腦上的驅動程式軟體&lt;/span&gt;&lt;/b&gt;&quot;&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXKqx7_QaXIOs0e8otiFA0ms7pfK_weQ02-2iYSg8P_lDZrMloqe8nf0ENb_CIsIT3vO67kwyd0Ok75rJQWl_WPDBQsT82qac8FKX99ixrHxe9K5P6wbKZcDMbrQFBaYbME_ad740tdBQ/s1600/2014-01-23_104520.png&quot; height=&quot;295&quot; width=&quot;400&quot; /&gt;
&lt;br /&gt;
完成後就會看到裝置啟動，並出現 &lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;XXX Android ADB Interface&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_F3aaZeayzl2mL-4zjtdJK8ns9Y5vcVIfN0b0Cr5Dimc6xMg1vCJuc_5Qc2Me7fft3amdMRiVi0I-IwmZA6F3EwP88V6NSJN-i5NZK_W7gOSEwaEP3mEwvxR78PZyWZ43FaI-sQcCrnM/s1600/2014-01-23_103905.png&quot; height=&quot;291&quot; width=&quot;400&quot; /&gt;
&lt;br /&gt;
4.測試是否連接成功&lt;br /&gt;
進入到第一步下載的 sdk 資料夾裡&lt;br /&gt;
D:\adt-bundle-windows-x86_64-20131030\sdk&lt;br /&gt;
然後在 platform-tools 資料夾上按住 Shift 鍵，然後再按滑鼠右鍵&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5CpmRhEUk65V67sUtwFUW3_1LHaBzFG2Oxh3ILpHakATlMSmbbIJcXX-XFLLj2hsq7F3ugmVCYfJ6j-pY92fSiaVqHxi7QooK2jzAuOu7qepFvTVY5Xpl4lnI3bIbHIadlJMJGB2Dc8I/s1600/2014-01-23_112020.png&quot; height=&quot;324&quot; width=&quot;640&quot; /&gt;
選擇&quot;&lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;在此處開啟命令視窗&lt;/b&gt;&lt;/span&gt;&quot;&lt;br /&gt;
(此功能只有 Win7 之後的版本才支援, XP使用者就要自行輸入 dos 指令進入到資料夾)&lt;br /&gt;
輸入 adb devices&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJbzQEvFV3dlN2pp8isYseau5IYKw9rDLwpFlFUZjB7I07Yjdjg0JZb0p17ccLzHCW_SEF3eTUyQKgI9CetjA5kwZ_DqSqt3OcxguSViUuidpl2wTcHCaCPemg3bgV-zwDCnLwcjBr14o/s1600/2014-01-23_112755.png&quot; height=&quot;258&quot; width=&quot;400&quot; /&gt;
如果看到一串數字，並顯示 device 就表示連線成功&lt;br /&gt;
5.新增環境變數(選擇性設定)&lt;br /&gt;
為了方便的使用 adb 指令&lt;br /&gt;
可以為 windows 設定變數&lt;br /&gt;
開啟我的電腦 / 內容 / 左邊的&quot;&lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;進階系統設定&lt;/b&gt;&lt;/span&gt;&quot;&lt;br /&gt;
點選下方 環境變數&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2rOrx_rrFSRoRL1PD1jj_Rim1ytVgCf_cCq0JCAM5hnPlNqcQk1odjJNXXvg40cu-EAZidrwrWrkRciqqxtfcLjbzFH8AW_kis0oc_TJdBJ4kad88Dg7S1owY5E9lqrurvF4WUy9I0QI/s1600/2014-01-23_113200.png&quot; /&gt;
&lt;br /&gt;
下方系統變數，找到 Path的選項，按下編輯&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRL0ToCI-BvlSBSPxt8yTdcKb7A2Q9AEBAAmgf_EtY18nJXTyDwtc0QjDUKXpcH97tRiheJxCtRVJMZMcPYxOJcxfbucX4fK9mfVhwkhY2wbpBzDMvJ1erJWW2DXLGkRyCEvmki8u0C4I/s1600/2014-01-23_113257.png&quot; /&gt;
&lt;br /&gt;
在變數值欄位的最後方加入&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;;D:\adt-bundle-windows-x86_64-20131030\sdk\platform-tools&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
注意前方有個分號, 完成後重開機&lt;br /&gt;
之後就可以在任意的路徑下使用 adb 指令&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;http://3.bp.blogspot.com/-ctYHWwQLaj0/UuCOTPokKqI/AAAAAAAAOw8/gAYOJpbV0oQ/s1600/2014-01-23_113608.png&quot; height=&quot;415&quot; width=&quot;640&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://milkmidi.blogspot.com/feeds/3689227197185975191/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2389124153774442796/3689227197185975191' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/3689227197185975191'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2389124153774442796/posts/default/3689227197185975191'/><link rel='alternate' type='text/html' href='http://milkmidi.blogspot.com/2014/01/android-01-sdkusbdriver.html' title='Android完全入門篇-01 安裝SDK與裝置USBDriver'/><author><name>milkmidi</name><uri>http://www.blogger.com/profile/03696025671272118687</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVjvk731DhBS69-035cveS12cvKsX5eJgyuLP9Z3_QLw05M90pVU35ANsvmVF6ERASDYpH7v5nRkgFjp7f_I4bV7eN15rw810AdxfrqkvlnZByLLZwfV9oD6mFU5_Ekk/s220/milkmidiBottle2007_100x100.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhME1YuTc0L9ZVAKozMolxItZggmZOCabkzgaHExUoAr1l73vYwEj_4YPy9FUh2VY3afeCs3XdpTpjhkktYHekue8rUr5tqESE_5sLcEpHVIAlVwU0WgchhLUjNnPQQ3gSp-KMqj6MzBms/s72-c/2014-01-23_110231.png" height="72" width="72"/><thr:total>0</thr:total></entry></feed>