AR Business card
I’m using the following AS3 libraries in this projectAR Business Card from James Alliban on Vimeo.
FLARToolkit
FLARManager
Papervision
TweenMax
papervision 3D 研究日誌 #0
I’m using the following AS3 libraries in this projectAR Business Card from James Alliban on Vimeo.
FLARToolkit
FLARManager
Papervision
TweenMax
Managing Scope
When JavaScript code is being executed, an execution context is created. The execution
context (also sometimes called the scope) defines the environment in which code is to
be executed. A global execution context is created upon page load, and additional
execution contexts are created as functions are executed, ultimately creating an execution
context stack where the topmost context is the active one.
Each execution context has a scope chain associated with it, which is used for identifier
resolution. The scope chain contains one or more variable objects that define in-scope
identifiers for the execution context. The global execution context has only one variable object in its scope chain, and this object defines all of the global variables and functions
available in JavaScript. When a function is created (but not executed), its internal
[[Scope]] property is assigned to contain the scope chain of the execution context in
which it was created (internal properties cannot be accessed through JavaScript, so you
cannot access this property directly). Later, when execution flows into a function, an
activation object is created and initialized with values for this, arguments, named
arguments, and any variables local to the function. The activation object appears first
in the execution context’s scope chain and is followed by the objects contained in the
function’s [[Scope]] property.
During code execution, identifiers such as variable and function names are resolved by
searching the scope chain of the execution context. Identifier resolution begins at the
front of the scope chain and proceeds toward the back. Consider the following code:
function add(num1, num2){
return num1 + num2;
}
var result = add(5, 10);
When this code is executed, the add function has a [[Scope]] property that contains
only the global variable object. As execution flows into the add function, a new execution
context is created, and an activation object containing this, arguments, num1, and
num2 is placed into the scope chain. Figure 7-1 illustrates the behind-the-scenes object
relationships that occur while the add function is being executed.
http://github.com/davglass/yui-tools/blob/5ae0ed588feef376f10fa91dd5a2e9154cd12484/tools.js
/**
* @method PixelToEm
* @description Divide your desired pixel width by 13 to find em width. Multiply that value by 0.9759 for IE via *width.
* @param {Integer} size The pixel size to convert to em.
* @return Object of sizes (2) {msie: size, other: size }
* @type Object
*/
PixelToEm: function(size) {
var data = {};
var sSize = (size / 13);
data.other = (Math.round(sSize * 100) / 100);
data.msie = (Math.round((sSize * 0.9759) * 100) / 100);
return data;
},
Media Player Classic Home Cinema
http://www.mobile01.com/topicdetail.php?f=174&t=1086593&p=3#12493064#12489360
先來分享一下Revo在Win7 / Vista底下調用DxVA硬解的方法:
註:用xp的朋友,只要把第一張圖片裡的選項選成「VMR9(無轉換)**」就可以直接在xp底下硬解了。
1. 下載我打包好的Media Player Classic - Home Cinema(5.79MB 7-Zip檔)。
2. 解開後(約38MB),會看到一個目錄(MPC-1050-Internal_DxVA)和MatroskaSplitter.exe安裝檔。
3. 先安裝Matroska Splitter,這是看MKV檔必備的分離器,安裝過程只要一路按「下一步」就好了。
4. 把MPC的主目錄放到自己想要的地方(設定都是帶著走的,換了電腦也能用)。
5. 打開MPC後按鍵盤上的「O」鍵(是英文字母,不是數字),確認設定和以下圖相同:
6. 然後就可以開始播放720p/1080p的MKV了!
7. 播放時,按下Ctrl+J,會顯示播放資訊,只要黃色框框裡是如下的資訊,就表示DxVA硬解有正確開啟(看CPU使用率也可以啦!)。
var cal = null;
var calOverlay = new YAHOO.widget.Overlay('cal-overlay', {
xy: [-5000, -5000],
visible: false,
width: '200px'
});
// align thte cal-overlay
calOverlay.beforeShowEvent.subscribe(function () {
calOverlay.cfg.setProperty('context', [
Dom.get('cal-context'), 'tl', 'bl'
]);
});
calOverlay.setBody('');
// render the calendar
calOverlay.renderEvent.subscribe(function () {
cal = new YAHOO.widget.Calendar("cal-container");
cal.selectEvent.subscribe(function (type, args, obj) {
Dom.get('cal-context').value = args[0][0].join('/');
calOverlay.hide();
}, cal, true);
cal.render();
});
calOverlay.render(document.body);
Event.on('cal-toggle', 'click', function () {
if (!Dom.get('cal-context').disabled) {
calOverlay.show();
}
});
// hide the cal-overlay if blur
var onCalOverlayBlur = function (e) {
var target = Event.getTarget(e);
if (!Dom.isAncestor('cal-overlay', target) && target.id != 'cal-toggle') {
calOverlay.hide();
}
};
Event.on(document.body, 'click', onCalOverlayBlur);
標籤: yui
function daysInMonth(month,year) {
var ds = String(monthNum+1)+'/0/'+String(yearNum);
var dd = new Date(ds);
return dd.getDate();
}
function daysInMonth(month,year) {
var dd = new Date(year, month, 0);
return dd.getDate();
}
var worker = new Worker('worker.js');
worker.onmessage = function (event) {
document.getElementById('result').textContent = event.data;
};
var n = 1;
search: while (true) {
n += 1;
for (var i = 2; i <= Math.sqrt(n); i += 1)
if (n % i == 0)
continue search;
// found a prime!
postMessage(n);
}
Workers provide a simple means for web content to run scripts in background threads. Once created, a worker can send messages to the spawning task by posting messages to an event handler specified by the creator.
Worker Threads
* Spawn OS-threads to run JavaScript
* Avoids window freezing
* Simple communication methods with main thread
– postMessage(), onmessage and onerror
* Has XMLHttpRequest Access, timeouts