computer -> properties -> advanced -> environment vars -> then make a new var like this
JAVA_TOOL_OPTIONS
and its value
-Xmx1024M
我的電腦 > 右鍵內容 > 進階 > 環境變數 > 系統變數"新增"變數值 > 名稱 JAVA_TOOL_OPTIONS > 值 -Xmx1024M
(1024 or 512..256..128)
5005: unknown error optimizing byte code
Tween function
Linear.easeNone
Back
Bounce
Circ
Cubic
Elastic
Expo
Quart
Quint
Sine
(xxx.easeIn, xxx.easeOut, xxx.easeInOut)
AS3 fullscreen or not
stage.displayState=StageDisplayState.FULL_SCREEN;
stage.displayState=StageDisplayState.NORMAL;
http can't find index.html??
ftp root folder -> .htaccess
DirectoryIndex index.htm index.html index.php
google tracking
in html
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-x']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
function GAPageView(url){_gaq.push(['_trackPageview', url]);}
function GAEventTrack(category, action, label){_gaq.push(['_trackEvent', category, action, label]);}
</script>
in as
tracking page view
GATracking.trackPageview("/index");
tracking event
GATracking.trackEvent("/index", "action", "做了啥");
GATracking.as -> author jacky
compare round, floor, ceil
int();無條件捨去
Math.round();四捨五入
Math.floor();無條件捨去
Math.ceil();無條件進位
SWF get parameter from html
in js
<script type="text/javascript">
function $G(){
var Url=top.window.location.href;
var u,g,StrBack='';
if(arguments[arguments.length-1]=="#")
u=Url.split("#");
else
u=Url.split("?");
if (u.length==1) g='';
else g=u[1];
if(g!=''){
gg=g.split("&");
var MaxI=gg.length;
str = arguments[0]+"=";
for(i=0;i<MaxI;i++){
if(gg[i].indexOf(str)==0) {
StrBack=gg[i].replace(str,"");
break;
}
}
}
return StrBack;
}
</script>
embedSWF("index.swf?id="+$G("param") , "flashcontent" , "100%" , "100%" , "10.0.0.0");
in html
index.swf?param=xxx
in as3
loaderInfo.parameters.param;
can get xxx
bitmap to png or jpg
import com.adobe.images.PNGEncoder;
import com.adobe.images.JPGEncoder;
var _bitmapData:BitmapData = new BitmapData(mc.width,mc.height);
_bitmapData.draw(mc);
var _byte:ByteArray = PNGEncoder.encode(_bitmapData);
//var _byte:ByteArray = JPGEncoder.encode(_bitmapData);
var _file:FileReference = new FileReference();
_file.save(_byte ,"file.png");
Facebook Graph api fql.query cookie fix
Facebook.fqlQuery("SELECT type, page_id FROM page_fan WHERE uid= "+uid+
" and page_id="+pageID+" and "+randRange(0,100), callbackfunction);
send random int!!!
Check Email Format
function isValidEmailAddress($str:String):Boolean {
return (($str == findValidEmailAddress($str)) ? true : false);
}
function findValidEmailAddress($str:String):String {
var pattern:RegExp = /\b[\w\.-]+@[\w\.-]+\.\w{2,4}\b/gi;
var result:Object = pattern.exec($str);
return ((result == null) ? "" : result[0]);
}
AS3 Performance note
Object pool > new Sprite();
array[0]='string' > array.push('string');
switch case > if else
* > /
for(i=0;i<j;i++) > for(var i=0;i<array.length;i++)
p.s remove listener(enterframe, mousemove, timer) when object remove on stage
AS3 setTimeout and Timer
setTimeout(function(){
}, 5000);
var myTimer:Timer= new Timer(5000, 1);
myTimer.addEventListener("timer", timerHandler);
myTimer.start();
function timerHandler(event:TimerEvent):void {
trace("timerHandler: " + event);
}
AS3 Random Range
function randRange(minNum:Number, maxNum:Number):Number {
return (Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum);
}
AS3 on resize
stage.addEventListener(Event.RESIZE, resizeHandler);
function resizeHandler(e:Event):void{
reSize();
}
function reSize():void{
}
reSize();
AS3 Open URL
navigateToURL(new URLRequest("http://www.google.com.tw"), '_blank');
'_self' also
in Chinese case
navigateToURL(new URLRequest(encodeURI("http://www.google.com.tw?中文")), '_blank');
js
var js:URLRequest=new URLRequest();
js.url="javascript:window.open('award.html','popper1','width=540,height=360');newWindow.focus(); void(0);";
pop_btn.addEventListener(MouseEvent.CLICK,openPopUp);
function openPopUp(evt:MouseEvent):void{
navigateToURL(js,'_self');
}
Facebook Graph API Login, PostData
facebook init
Facebook.init('App ID', initLogin);
function initLogin(response:Object, fail:Object):void {//facebook init
}
facebook login
Facebook.login(handleLogin,{perms:"user_birthday,read_stream,publish_stream,user_photos"});
function handleLogin(response:Object, fail:Object):void {//facebook login
if(response!=null){
Facebook.api('/me', onMyInfoLoaded);
}
}
load facebook info and post data
function onMyInfoLoaded(response:Object,fail:Object):void {//facebook info success
if(response!=null){
var params:Object = {
source: 'http://xxx.jpg',
picture: 'http://xxx.jpg',
message: 'text',
link: 'http://adidas-oba2011-2.youthwant.com.tw',
name: 'Adidas is all in',
caption: '內容',
description: '內容'
};
Facebook.postData('/me/feed', requestHandler, params);
}
}
function requestHandler(result:Object, fail:Object):void{
if (result != null){
if (result.error_msg != null){
//error
}else{
//success
}
}
if (fail != null){
//error
}
}
Adobe Flash Player Debug
always for facebook application debug
Debug Flash Player
http://www.adobe.com/support/flashplayer/downloads.html
Get Params From SWF
loaderInfo.parameters.id
in as can get http://yoururl.com/xxx.swf?id=xxx
Crossdomain Load Image as Bitmap
var loaderContext:LoaderContext = new LoaderContext ();
loaderContext.checkPolicyFile = true;
loaderContext.applicationDomain = ApplicationDomain.currentDomain;
pic_loader.load(new URLRequest("url"), loaderContext);
Social Website URL Share
twitter:
http://twitter.com/?status=xxx http://xxx
plurk:
link: http://plurk.com/?status=www.google.com(xxx)
image: http://plurk.com/?status=http://xxx.jpg
facebook:
http://www.facebook.com/share.php?u=http://xxx