Skip to content

Instantly share code, notes, and snippets.

@RhinoLu
RhinoLu / gist:3445597
Created August 24, 2012 05:03
生肖與星座
/**
* 參考 http://little-bill.iteye.com/blog/724570
**/
private function getAstro(ld_month:uint, ld_day:uint):String
{
var s:String = "魔羯水瓶双鱼牧羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯";
var arr:Array = [20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22];
return s.substr(ld_month * 2 - (ld_day < arr[ld_month - 1] ? 2 : 0), 2);
}
@RhinoLu
RhinoLu / ValidateURL.as
Created August 25, 2012 07:22
Validate URL 檢查URL是否有效
package
{
/**
* @link http://stackoverflow.com/questions/3455448/regex-url-problem
* @param _url
* @return
*/
public function ValidateURL(_url:String):String
{
var pattern:RegExp = new RegExp(
@RhinoLu
RhinoLu / gist:3511049
Created August 29, 2012 11:25
AS3, HTML文字欄位點擊事件
var txt:TextField = new TextField();
txt.name = "t" + i;
txt.autoSize = TextFieldAutoSize.LEFT;
txt.htmlText = "<font size='" + 14 + "'><a href='event:" + i + "'>" + "Hello World!" + "</a></font> ";
txt.styleSheet = getStyleSheet();
txt.addEventListener(TextEvent.LINK, onHyperLinkClick);
addChild(txt);
private function onHyperLinkClick(e:TextEvent):void
{
@RhinoLu
RhinoLu / MyTextScroll.as
Created September 1, 2012 14:35
AS3 TestField ScrollBar 文字欄位捲動軸
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import flash.text.TextField;
/**
* @usage
{
"台北市": {
"中正區": "100",
"大同區": "103",
"中山區": "104",
"松山區": "105",
"大安區": "106",
"萬華區": "108",
"信義區": "110",
"士林區": "111",
@RhinoLu
RhinoLu / gist:3682626
Created September 9, 2012 04:38
解決 swffit 在 IE9 下出現捲軸(scroll bar)的問題
/* 解决swffit在ie9下的bug */
object
{
position: absolute;
outline: none;
}
@RhinoLu
RhinoLu / RelativeDate.as
Created October 5, 2012 03:35
[Util] Date utility by Charles Bihis (產生易閱讀的日期格式,如兩天前...)
package com.adobe.date
{
import com.adobe.utils.DateUtil;
/**
* Utility class to help create human-readable Strings representing
* the difference in time from two different dates (e.g. "just now"
* or "2 hours ago" or "13 minutes from now").
*
* @author Charles Bihis (www.whoischarles.com)
@RhinoLu
RhinoLu / GoogleShortener.as
Created October 23, 2012 09:10
Google Url Shortener 縮短網址
package
{
import flash.external.ExternalInterface;
/**
* @author http://www.facebook.com/rhino.lu
* @link https://developers.google.com/url-shortener/v1/getting_started
* html要嵌入 <script src="https://apis.google.com/js/client.js"></script>
*
*
*/
@RhinoLu
RhinoLu / gist:4146872
Created November 26, 2012 06:37
使用 TweenMax 製作漂浮效果
TweenMax.to(something, 1, new TweenMaxVars().y(50, true).ease(Quad.easeInOut).yoyo(true).repeat(-1).vars);
@RhinoLu
RhinoLu / gist:4170147
Last active October 13, 2015 08:48
Facebook tag photo
// 授權需求:publish_stream,user_photos
var _array:Array = [];
for (var i:int = 0; i < postArray.length; i++)
{
_array.push( { "tag_uid":postArray[i].id } ); // tag_uid < 文件似乎沒有
}
var postObj:Object = { };
//postObj.to = postArray[0].id; // 單人