2011年12月30日 星期五

FlashDevelop compile swfs using a single class file

標題很難下..XD
大家應該有遇過進行小測試時,只想隨便寫個 as
要怎麼測試,又不想特別開一個 Project
更不想開肥大的 Flash CS5 IDE
那怎麼辦呢??

2011年12月16日 星期五

flash countdown timer 倒數計時器

關於 flash 倒數計時器,網路上有很多相關的文章,
但大多是抓取 client 端時間,
本篇加入 server 端時間校正,
防止使用者更改系統時間造成問題。

2011年12月15日 星期四

how to get a page custom attribute in gaia

in site.xml
<page id="index" src="index.swf" hiddenOverviewTxt="false">

using node to get page attribute

Gaia.api.getPage(Pages.INDEX).node.@hiddenOverviewTxt
or
page.node.@hiddenOverviewTxt

2011年12月6日 星期二

wget tip


用來用去還是 wget 最好用呀~~

enable cookies
wget --cookies=on --keep-session-cookies --save-cookies=cookie.txt http://your.url

referer url and load cookies
wget --referer=http://your.referer.url --cookies=on --load-cookies=cookie.txt http://your.url

post data
wget --post-file post.txt http://your.url
wget --post-data="type=APP&nick=nickname" http://your.url

in post.txt(on windows)
type=APP&nick=nickname

user agent
--user-agent="Mozilla/5.0"

2011年11月21日 星期一

passing variable to gaia page

passing variable to gaia page

using deeplink

Gaia.api.goto(Pages.YOUR_PAGE + "/variable);

function transitionIn():void
{
    var type:String = Gaia.api.getDeeplink().substr(Gaia.api.getDeeplink().lastIndexOf("/") + 1);
    handleDeeplink(type);
}
function handleDeeplink(__arg:String):void
{
    // do something...
}

2011年10月7日 星期五

away3d how to move 3D object along a path - part2

preFab 還提供兩種工具 Path Extruder and Path Animator
Path Extruder 可以在 Path 上貼上材質(ie:草皮/柏油/水泥...etc.)
可以用 Geometry -> Path -> Path Extruder
首先點出你要的物件

setting:
select path
subdivision -> 4
closepath
allgntopath
coversegment
mapfit
選材質
build

Path Animator 可以用來預覽效果
Geometry -> Path Animator

seletc path
use camera
offset y:100
allgn to path
preview(camera 沿著 path 移動)

use Object3d
object(your car)
offset y:100
allgn to path
preview(3d object 沿著 path 移動)

away3d how to move 3D object along a path - part1

away3d how to move 3D object along a path
away3d 裡有支援 path animator,可以沿著路徑移動 3D 物件,
以往必需先自己建立路徑,再丟給 PathAnimator 處理

pseudocode:
var aPath:Array = [
new Vector3D(-1000, -1000, -2000),
new Vector3D(-1000, 0, 0),
new Vector3D(1000, 0, 0),
new Vector3D(1000, 1000, -2000),
];
var p:Path = new Path(aPath);
pa = new PathAnimator(path, arrow, o);

簡單的路徑可以自己建立,但是複雜的路徑
這樣搞大概永遠都下不了班,
為了讓大家能夠準時下班,這裡介紹一個好用的工具

2011年10月4日 星期二

away3d load obj/md2/3ds/mqo model

away3d load obj/md2/3ds/mqo model
away3d 可以載入多種 3D 格式,
有興趣可以去翻翻 away3d.loaders。

load obj
loader = Obj.load("resource/Static.obj")

load 3ds
loader = Max3DS.load("resource/monster.3DS", { scaling:5.0 });

load mqo
loader = Metasequoia.load("resource/mion/mion.mqo");

load md2(following md2 texture path)
loader = Md2.load("resource/ogre.md2", { scaling:0.05 } );

objcontainer = new ObjectContainer3D(loader);
scene.addChild(objcontainer);

away3d cube/skybox material

away3d cube/skybox material

cube 六個面貼上相同的材質
cube = new Cube( { material:"blue#white", x: -100, width:50, height:50, depth:50 } );
或者是
cube = new Cube();
cube.material = material;
cube.width = 200;
cube.height = 200;
cube.depth = 200;

cube 六個面貼上不同的材質
cube = new Cube();
cubeMaterial = new CubeMaterialsData();
cubeMaterial.front = new ColorMaterial("random");
cubeMaterial.back = material2;
cubeMaterial.bottom = new ColorMaterial("random");
cubeMaterial.top = new ColorMaterial("random");
cubeMaterial.left = material1;
cubeMaterial.right = new ColorMaterial("random");
cube.cubeMaterials = cubeMaterial;

away3d camera note

away3d camera note
camera 相關原理可以先參考這兩篇
http://www.flashmagazine.com/Tutorials/detail/away3d_basics_the_cameras/
http://blog.tartiflop.com/2008/08/understanding-zoom-focus-and-field-of-view-in-papervision3d/
away3d 有四種 camera,分別是
camera3D:default camera
TargetCamera3D:automatically look at a specified target object
SpringCam:1st and 3rd person camera
HoverCamera3D:hover round a specified target object

本文介紹(最常用) HoverCamera3D,
利用改變 camera.panAngle 及 camera.tileAngle
來產生旋轉及放大縮小的 3D 效果。

away3d video material demo

很久沒碰 away3d,最近因為專案需要,重新看了一下,
這才發現 away3d 做了不少更動,
本篇是以 away3d 3.6 進行 demo
以 videoMaterial 當材質
建立一個可轉動的 cube。

phpfog note

想要玩 php 要自己架 server 弄有的沒的,
現在不用這麼麻煩了,試試 phpfog

基本上操作界面都很直覺,就不多說了,
設定好 SSH key
就可以用 git control source code

on windows using git bash
git clone git@git01.phpfog.com:XXX.phpfogapp.com
git status
git add .
git commit -m "init import"
git push

// debug
error_reporting(E_ALL);
ini_set('display_errors', '1');

另外付費才能修改 include_path 這點倒是比較麻煩。

google+ PHP API

這篇算是上一篇的延續,
google+ 有提供官方 php api

下載後修改 index.php

$client->setApplicationName("Google+ Application Name");
$client->setClientId('your id');
$client->setClientSecret('your secret');
$client->setRedirectUri('https://your.url');
$client->setDeveloperKey('your key'); // Simple API Access

即可取得 access token,差別在於
這邊取得 token 的方式為 server-side flow
response_type=code

之前的方式為 client-side flow
response_type=token



2011年9月30日 星期五

google plus api note


1. 準備
先去 google console
開啟 Google+ api service (Courtesy limit: 1,000 queries/day)
再來去 API Access create client ID and simple API Access
勾選 Application type and Redirect URI 填一填
Redirect URI:Google should redirect the browser after the user allows (or denies) the authorization request(簡單講就是授權完要導去的頁面)

2. API 流程
OAuth2->user 登入/同意取得權限->導回 redirect_url 並取得 access_token ->API Call

2011年9月26日 星期一

event hijacking - flash gaia framework

gaia event hijacking 可是相當博大精深的呀~~
首先要知道有哪些 gaia flow events 可用
beforeGoto
afterGoto
beforeTransitionOut
afterTransitionOut
beforePreload
afterPreload
beforeTransitionIn
afterTransitionIn
afterComplete(no hijacking)

假設要在 transitionIn 之前做一些事,
先宣告
private var releaseGaia:Function;
// in constructor
releaseGaia = Gaia.api.beforeTransitionIn(onBeforeTransitionIn,true);

private function onBeforeTransitionIn(event:GaiaEvent):void {
  // do something...
  releaseGaia();
}

另外在 Navigation 裡常用的手法,
// in init
Gaia.api.afterGoto(setPageId, false, false);

private function setPageId(e:GaiaEvent):void {
  trace(e.validBranch);
}
用來做 breadcrumb  還蠻方便的。

[ref]
http://www.gaiaflashframework.com/wiki/index.php?title=Events_and_Hijacking

2011年9月23日 星期五

facebook actionscript api (照片+相簿) - part3

方法一
facebook 上傳照片 + 開相簿:
自動開相簿 + post wall,不想 po 牆請設 no_story:'1'
var params:Object = {image:bitmap, message:'my message', fileName:'myfilename'};
Facebook.api("me/photos", onSaveToPhotoAlbumComplete, params);

2011年6月29日 星期三

[flash<->js] passing json using ExternalInterface

js call flash function(js -> flash)
[in flash]
ExternalInterface.addCallback("getData", fromJs_getData);

[in html]
var obj = document.getElementById("myflashcontent");
obj.getData();

flash call js function(flash ->js)
[in flash]
ExternalInterface.call("sendData", args);

[in html]
function sendData() {
console.log("sendData[0]:"+arguments[0]);
)

Google Maps API for Flash - 基本用法

Google Maps API for Flash
http://code.google.com/intl/zh-TW/apis/maps/documentation/flash/

先去這裡申請 API key
http://code.google.com/intl/zh-TW/apis/maps/signup.html

下載SDK
http://maps.googleapis.com/maps/flash/release/sdk.zip
flash use map_1_20.swc(swf檔案比用map_flex_1_20.swc小)

2011年6月8日 星期三

facebook actionscript api - part2

前一篇寫的落落長,避免以後忘記
包成 swc 方便使用,都已處理 facebook登入 及 取得權限 的部分。
facebook 相簿列表:FBAlbums.swc
facebook 好友列表:FBFriends.swc

範例:
import iqcat.ui.FBAlbumsList;
//import iqcat.ui.FBFriendsList;
//傳入參數:appid, 座標及長寬
var o:Object = { appid:APP_ID, x:10, y:50, w:620, h:330};
addChild(new FBAlbumsList(o));
//addChild(new FBFriendsList(o));

2011年5月24日 星期二

facebook actionscript api - part1

facebook actionscript api
先去下載
http://code.google.com/p/facebook-actionscript-api/

goto http://www.facebook.com/developers/
"Set Up New App"
get AppID

參考FlashWebExample
in html
<script src="http://connect.facebook.net/zh_TW/all.js" type="text/javascript">
</script>
<div id="fb-root">
</div>