Skip to content

Instantly share code, notes, and snippets.

@RhinoLu
RhinoLu / gist:8e12b9746cb5f2d445e2
Last active August 29, 2015 14:06
browser scroll bar smoothing 平滑
// http://bassta.bg/2013/05/smooth-page-scrolling-with-tweenmax/
$(function(){
var $window = $(window);
var scrollTime = 1.2;
var scrollDistance = 170;
$window.on("mousewheel DOMMouseScroll", function(event){
@RhinoLu
RhinoLu / gist:96c37558a1d75c463468
Created September 23, 2014 11:30
獲取網址參數 url parameter
// http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
var prodId = getParameterByName('prodId');
@RhinoLu
RhinoLu / Main.as
Created July 3, 2014 07:41
AS3 Gaia Framework fake loading
override protected function init():void
{
// 0ms, 表示一定會看到 Preload,至少會閃一下
// 若首頁一定要看到 loading 可以這樣做
// 之後要設回 150ms
Gaia.api.setPreloaderDelay(0);
initComplete();
}
@RhinoLu
RhinoLu / gist:5747584
Created June 10, 2013 09:39
[AS3] Skinning a combobox component in actionscript 3
//http://www.murtensaerbi.be/blog/index.php/2008/08/11/skinning-a-combobox-component-in-actionscript-3/
// create a new textformat and set the style of it
var myFormat : TextFormat = new TextFormat();
myFormat.font = "Cooper Std Black";
myFormat.color = 0xffffff;
myFormat.size = 13;
myFormat.indent = 4;
@RhinoLu
RhinoLu / sample.html
Created January 22, 2013 01:45
html 上下左右置中
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title></title>
<style type="text/css">
html, body { height:100%; }
body { margin:0; padding:0; overflow:hidden; text-align:left; background-color: #222; }
object:focus { outline:none; }
#container {
@RhinoLu
RhinoLu / gist:4561833
Created January 18, 2013 02:21
驗證 Youtube 影片是否存在
// 驗證 Youtube *******************************************************************
private function validateHaveVideoID(str:String):String
{
var pattern:RegExp = /(?<=v(\=|\/))([-a-zA-Z0-9_]+)|(?<=youtu\.be\/)([-a-zA-Z0-9_]+)/gm;
var result:Object = pattern.exec(str);
//trace(result);
if (result) {
return result[0];
}else {
return null;
@RhinoLu
RhinoLu / gist:4561786
Created January 18, 2013 02:13
Get YouTube Video ID
/*
http://gskinner.com/RegExr/?2tsac
Author: Roberto Rama
*/
var pattern:RegExp = /(?<=v(\=|\/))([-a-zA-Z0-9_]+)|(?<=youtu\.be\/)([-a-zA-Z0-9_]+)/gm;
var result:Object = pattern.exec("http://www.youtube.com/watch?v=9bZkp7q19f0");
trace(result);
@RhinoLu
RhinoLu / VideoClip.as
Created January 18, 2013 02:00
Flash 載入 f4v, mp4, flv...等影片,需播放介面元件
package pages
{
import com.greensock.events.LoaderEvent;
import com.greensock.layout.ScaleMode;
import com.greensock.loading.data.VideoLoaderVars;
import com.greensock.loading.VideoLoader;
import com.robertpataki.heartcode.ProgressIndicator;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
@RhinoLu
RhinoLu / YoutubeClip.as
Created January 18, 2013 01:53
Flash 載入 Youtube 影片
package pages
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
import flash.system.Security;
public class YoutubeClip extends Sprite
{
@RhinoLu
RhinoLu / gist:4450939
Created January 4, 2013 08:38
YouTube 相關
縮圖:
http://i.ytimg.com/vi/VIDEO_ID/0.jpg (medium sized image)
http://i.ytimg.com/vi/VIDEO_ID/1.jpg (Thumbnail)
http://i.ytimg.com/vi/VIDEO_ID/2.jpg (Thumbnail)
http://i.ytimg.com/vi/VIDEO_ID/3.jpg (Thumbnail)
http://i.ytimg.com/vi/VIDEO_ID/maxresdefault.jpg (Maximum resolution)
影片:
http://www.youtube.com/v/VIDEO_ID?version=3&rel=0