2012年10月4日 星期四

ByteArray轉base64

class download

var base64Bytes:String = Base64.encodeByteArray(ByteArray);

ref:http://www.cnblogs.com/meteoric_cry/archive/2011/06/18/2084371.html

2012年9月13日 星期四

RadioButton.selected=false;無效!!!!!!!

btn.addEventListener(MouseEvent.CLICK, aaa);
private function aaa(e:MouseEvent):void 
{
aa.selected = false;
}

照理來講按下btn的時候aa這個RadioButton會取消選取嘛~
那你就錯了!!!!!!
他沒反應他沒反應他沒反應他沒反應他沒反應他沒反應他沒反應他沒反應他沒反應他沒反應

要改成以下
btn.addEventListener(MouseEvent.CLICK, aaa);
private function aaa(e:MouseEvent):void 
{
//aa.selected = false;
bb.selected = true;
bb.visible = false;
}

bb跟aa同一個group 按下的時候去選取bb 這樣aa就會取消選取了  同一時間把bb 隱藏

2012年9月2日 星期日

gaia note


Q:偵測目前的scene
A:var myParentSrc:String = page.branch;//取得paga路徑 ex:index/nav/home


if(ExternalInterface.available){//只有ExternalInterface可用时才执行JS调用。
Tracking.track(“alert”, route);
}


Q:一開始發布甚麼都沒有居然會自己有背景!!
A:new Scaffold(this);這行註解調


Q:左上角的menu如何刪除
A:先刪除每個page的new Scaffold(this);這行,再把Scaffold.swf刪掉


Q:換頁中間的loading哩?
A:跟一開始LOADING依樣


Q:取得上一層的路徑 
A:var myParentSrc:String = page.getParent().src;//但是nav= =


Q:直接去某一頁
A:Gaia.api.goto("index/nav/about");


Q:右鍵不要menu
A:<site title="Gaia Framework Site: %PAGE%" menu="false">//menu設為false


Q:除了page nav跟preloading切開?!不能直接發!?
A:放在INDEX.FLA(待測,MAIN等於一個LOADER


Q:preloader一直是黑色的!?
A:一切都是誤會!!沒有什麼顏色效果設定需要改,把場景上的刪掉再重新拉出來就變彩色的了...

Q:一執行一片空白!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
A:可以用ADDED_TO_STAGE來載入 BUT仍有一些問題
或是寫隻CLASS!(待測...
如果用ADDED_TO_STAGE來載入除了preloader跟nav有些問題之外,其他page好像ok

Q:menu 跑的影格名稱找不到!
A:無解!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
用原始方法解決吧.........


/**
 * Gaia Framework Global Nav Lesson
 * @author Steven Sacks
 */
package pages
{
import com.gaiaframework.templates.AbstractPage;
import com.gaiaframework.events.*;
import com.gaiaframework.debug.*;
import com.gaiaframework.api.*;
import flash.display.*;
import flash.events.*;
import com.greensock.TweenMax;

public class NavPage extends AbstractPage
{
private var buttons:Array;
public var homeBTN:MovieClip;
public var aboutBTN:MovieClip;
public function NavPage()
{
super();
alpha = 0;
//new Scaffold(this);
initButtons();
}
public function initButtons():void
{
homeBTN.branch = "index/nav/home";
aboutBTN.branch = "index/nav/about";
buttons = [homeBTN, aboutBTN];
var i:int = buttons.length;
while (i--)
{
buttons[i].buttonMode = true;
buttons[i].mouseChildren = false;
buttons[i].addEventListener(MouseEvent.CLICK, onClick);
buttons[i].addEventListener(MouseEvent.MOUSE_OVER, onOver);
buttons[i].addEventListener(MouseEvent.MOUSE_OUT, onOut);
}
Gaia.api.afterGoto(onAfterGoto);
updateButtonStates(Gaia.api.getCurrentBranch());
}

public function onOver(event:MouseEvent):void {
event.target.gotoAndPlay("up");
}
public function onOut(event:MouseEvent):void {
//event.target.gotoAndPlay("selected");
TweenMax.to(event.target, .5, {frame:1});
}
private function onClick(event:MouseEvent):void
{
Gaia.api.goto(MovieClip(event.target).branch);
}
private function onAfterGoto(event:GaiaEvent):void
{
updateButtonStates(event.validBranch);
}
private function updateButtonStates(branch:String):void
{
var i:int = buttons.length;
while (i--)
{
var btn:MovieClip = buttons[i];
if (branch != btn.branch)
{
btn.gotoAndStop("up");
btn.enabled = true;
btn.addEventListener(MouseEvent.MOUSE_OUT, onOut);
btn.addEventListener(MouseEvent.MOUSE_OVER, onOver);
}
else
{
btn.removeEventListener(MouseEvent.MOUSE_OVER, onOver);
btn.removeEventListener(MouseEvent.MOUSE_OUT, onOut);
btn.gotoAndStop("selected");
btn.enabled = false;
}
}
}
override public function transitionIn():void
{
super.transitionIn();
TweenMax.to(this, 0.3, {alpha:1, onComplete:transitionInComplete});
}
override public function transitionOut():void
{
super.transitionOut();
TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});
}
}
}
--------------------------------------------更正版--------------------------------------------------------
/**
 * Gaia Framework Global Nav Lesson
 * @author Steven Sacks
 */
package pages
{
import com.gaiaframework.templates.AbstractPage;
import com.gaiaframework.events.*;
import com.gaiaframework.debug.*;
import com.gaiaframework.api.*;
import flash.display.*;
import flash.events.*;
import com.greensock.TweenMax;
public class NavPage extends AbstractPage
{
private var buttons:Array;
public var homeBTN:MovieClip;
public var aboutBTN:MovieClip;
private var flag :Boolean = false;
private var _Str :String;
private var mcmc :Object = null;
public function NavPage()
{
super();
alpha = 0;
//new Scaffold(this);
addEventListener(Event.ADDED_TO_STAGE, onAdd);
addEventListener(Event.REMOVED_FROM_STAGE, onRemove);
}
private function onRemove(e:Event):void 
{
removeEventListener(Event.REMOVED_FROM_STAGE, onRemove);
}
private function onAdd(e:Event):void 
{
removeEventListener(Event.ADDED_TO_STAGE, onAdd);
initButtons(); 
transitionIn();
}
public function initButtons():void
{
homeBTN.branch = "index/nav/home";
aboutBTN.branch = "index/nav/about";
buttons = [homeBTN, aboutBTN];
var i:int = buttons.length;
while (i--)
{
buttons[i].buttonMode = true;
buttons[i].mouseChildren = false;
buttons[i].addEventListener(MouseEvent.CLICK, onClick);
buttons[i].addEventListener(MouseEvent.ROLL_OVER, onOver);
buttons[i].addEventListener(MouseEvent.ROLL_OUT, onOut);
buttons[i].addEventListener(Event.ENTER_FRAME, BTNEnterFrame);
}
Gaia.api.afterGoto(onAfterGoto);
updateButtonStates(Gaia.api.getCurrentBranch());
}
private function BTNEnterFrame(e:Event):void 
{
if (mcmc != null) {
var _mc:MovieClip =mcmc as MovieClip;
if (flag) {
if (_mc.currentFrame != _mc.totalFrames) {
_mc.nextFrame();
}
}else {
if (_mc.currentFrame != 1) {
_mc.prevFrame();
}
}
}
}
public function onOver(event:MouseEvent):void {
flag = true;
mcmc = event.target;
}
public function onOut(event:MouseEvent):void {
flag = false;
mcmc = event.target;
}
private function onClick(event:MouseEvent):void
{
Gaia.api.goto(MovieClip(event.target).branch);
}
private function onAfterGoto(event:GaiaEvent):void
{
updateButtonStates(event.validBranch);
}
private function updateButtonStates(branch:String):void
{
var i:int = buttons.length;
while (i--)
{
var btn:MovieClip = buttons[i];
if (branch != btn.branch)
{
btn.gotoAndStop("up");
btn.enabled = true;
btn.addEventListener(MouseEvent.ROLL_OUT, onOut);
btn.addEventListener(MouseEvent.ROLL_OVER, onOver);
}
else
{
btn.removeEventListener(MouseEvent.ROLL_OVER, onOver);
btn.removeEventListener(MouseEvent.ROLL_OUT, onOut);
btn.gotoAndStop("selected");
btn.enabled = false;
}
}
}
override public function transitionIn():void 
{
super.transitionIn();
TweenMax.to(this, 0.3, { alpha:1, onComplete:transitionInComplete } );
}
override public function transitionOut():void 
{
super.transitionOut();
TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});
}
}
}






2012年7月17日 星期二

OMG!!!FLASHEFF真是個好東西!!!

http://www.flasheff.com/

import flash.events.IOErrorEvent;
import com.jumpeye.Events.FLASHEFFEvents;

aaa.addEventListener(MouseEvent.CLICK, clickHandler);
//bbb是在原件上那個flashffe的名字
function clickHandler(event:MouseEvent):void {
  bbb.show()
}

2012年7月15日 星期日

progression複習


看目前的sceneid有沒有包在"/index/portfolio"之下
if (new SceneId("/index/portfolio").contains(manager.currentSceneId))

看目前的sceneid是不是"/index/portfolio/p1"
if (manager.destinedSceneId.equals(new SceneId("/index/portfolio/p1")))

在SceneObject下多加子Scene

override protected function atSceneLoad():void
{
addScene(new P1Scene("p1"));
addScene(new P2Scene("p2"));
addScene(new P3Scene("p3"));
}
子scene-  P1Scene.as
init的時候
_cast = new PortfolioCast(0, 2);//帶參數給cast





不用腦FQL語法

自己以及朋友的uid,姓名,以及50x50的頭像連結
SELECT uid, name, pic_square FROM user WHERE uid = me() OR uid IN (SELECT uid2 FROM friend WHERE uid1 = me())



SELECT uid, name, pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
http://jasonblog.tw/2011/12/facebook-comments-for-blogger.html


自己的uid 名字小圖
SELECT uid, name, pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())


某id的相簿名稱相簿id
SELECT name,aid FROM album  WHERE aid IN (SELECT aid  FROM album WHERE owner = 要查的fbid )


fb大張大頭貼
SELECT src_big FROM photo WHERE pid IN (SELECT cover_pid FROM album WHERE owner ='要查的fbid' AND type = 'profile')


檢查是否是粉絲
SELECT page_id FROM page_fan WHERE uid = me() and page_id = '應用程式 ID / API 鑰匙'


撈某一id的大頭
SELECT pic_square FROM user WHERE uid =要查的fbid


http://developers.facebook.com/docs/reference/api/permissions/
允許頁


http://developers.facebook.com/tools/explorer
測試fql
/fql?q="你的fql"


Tag朋友


var _loc_2:* = new Array();//tag框框
_loc_2.push( { tag_uid:_fid, x:100, y:0} );
_loc_2.push( { tag_uid:_uid, x:0, y:0 } );
var _loc_3:Object = new Object();
_loc_3 = {message:_uname+'分享了一個好心情的禮物給 '+_fname+_stringPage._text.text+'轉個念頭轉個彎,一起擁有幸福好心情。'+('@'+_uname), fileName:"filename", image:bitmap, tags:JSON.encode(_loc_2)};
Facebook.api("/" +_uid + "/photos", this.onUploadCompleteHandler, _loc_3, "POST");



tag朋友附連結
"@[100000406220851:Name]"
_loc_5 = {message:"@["+uid+":Name]"+"和"+"@["+fbid+":Name]"+msg, fileName:"filename", image:_bitmap};

Fql排序
Facebook.fqlQuery("SELECT uid, name, pic_square  FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 ='" +uid + "')ORDER BY name", getFriend);






2012年3月29日 星期四

好像很厲害的正則表示法

http://www.minwt.com/?p=1917