starling gaming development

2015年6月19日 星期五 by Hu, Ching-Hsiang

because it's very important
so I need write it down
if you create a lot animation flash 2D game (include sprite sheet, video, particle)
most of time we will use starling to developer(GPU render)
but texture have resource limit
so my experience is :
1. 1280x720 (don't use 1920x1080)
2. StarlingSwf (very useful tools for timeline animation)
3. object pool (don't create object every time, or you need be sure texture dispose)

good luck have fun

Filed under having 0 意見  

starling gif decoder memory problem

2015年6月15日 星期一 by Hu, Ching-Hsiang

as3 starling gif decoder use https://github.com/honzabrecka/async-gif-decoder if you need refresh gif gallery all the time, or need show a lot gif image in same time use this library will have memory problem so you need modify "com/jx/gif/GPUGIF.as" change cachedTextures to public public var cachedTextures:Vector.; then in your code, every time refresh GPUGIF, you need if(gif.cachedTextures){ for(i=0;i < gif.cachedTextures.length;i++){ gif.cachedTextures[i].dispose(); } gif.dispose(); gif.texture.dispose(); } in this way, you can free 90% memory, if you have better way please let me know!! :)

Filed under having 0 意見  

starling right click

2015年6月10日 星期三 by Hu, Ching-Hsiang

starling/core/Starling.as case TouchEvent.TOUCH_END: phase = TouchPhase.ENDED; break; case MouseEvent.MOUSE_DOWN: phase = TouchPhase.BEGAN; break; case MouseEvent.MOUSE_UP: phase = TouchPhase.ENDED; break; + case MouseEvent.RIGHT_MOUSE_DOWN: phase = TouchPhase.RIGHT_BEGAN; break; + case MouseEvent.RIGHT_MOUSE_UP: phase = TouchPhase.RIGHT_ENDED; break; case MouseEvent.MOUSE_MOVE: phase = (mLeftMouseDown ? TouchPhase.MOVED : TouchPhase.HOVER); break; } ... ... ... if (!multitouchEnabled || Mouse.supportsCursor) - types.push(MouseEvent.MOUSE_DOWN, MouseEvent.MOUSE_MOVE, MouseEvent.MOUSE_UP); + types.push(MouseEvent.MOUSE_DOWN, MouseEvent.MOUSE_MOVE, MouseEvent.MOUSE_UP, MouseEvent.RIGHT_MOUSE_DOWN, MouseEvent.RIGHT_MOUSE_UP); return types; } starling/events/TouchPhase.as public static const HOVER:String = "hover"; + + /** Only available for mouse input: right mouse button was pressed */ + public static var RIGHT_BEGAN : String = "right_began" + + /** Only available for mouse input: right mouse button was released */ + public static const RIGHT_ENDED : String = "right_ended"; /** The finger touched the screen just now, or the mouse button was pressed. */ public static const BEGAN:String = "began";

Filed under having 0 意見  

as3 get radians between three point

2014年7月29日 星期二 by Hu, Ching-Hsiang

// Center point is p1; angle returned in radians function findAngle(p0:Point,p1:Point,p2:Point) { var a = Math.pow(p1.x-p0.x,2) + Math.pow(p1.y-p0.y,2), b = Math.pow(p1.x-p2.x,2) + Math.pow(p1.y-p2.y,2), c = Math.pow(p2.x-p0.x,2) + Math.pow(p2.y-p0.y,2); return Math.acos( (a+b-c) / Math.sqrt(4*a*b) ); }

Filed under having 0 意見  

as3 radians to degrees

by Hu, Ching-Hsiang

var degrees:Number = radians*180/Math.PI ;

Filed under having 0 意見  

AS3 String to Boolean

2013年12月4日 星期三 by Hu, Ching-Hsiang

var boolValue:Boolean = (boolString == "true") ? true : false; just one line! I like it!

Filed under having 0 意見  

old mac install win64bit

2013年4月28日 星期日 by Hu, Ching-Hsiang

http://www.iruberleet.org/2011/10/12/fixing-select-cd-rom-boot-type-when-installing-64bit-windows/

Filed under having 0 意見  

air for mobile device keep awake

2013年4月23日 星期二 by Hu, Ching-Hsiang

it’s very easy to make the device stay awake. First you need to enable the following two permissions in the -app.xml file:

<uses-permission android:name="android.permission.WAKE_LOCK">
<uses-permission android:name="android.permission.DISABLE_KEYGUARD">
</uses-permission></uses-permission>



Then you need to use this simple line of code anytime you want to keep the device awake: NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE; To enable the device to go to sleep again: NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.NORMAL;

Filed under having 0 意見  

as3 text to speech

2013年3月27日 星期三 by Hu, Ching-Hsiang

var req:URLRequest= new URLRequest( "http://translate.google.com/translate_tts ?ie=UTF-8&tl=zh-TW&q=" + encodeURI("中文")); var snd:Sound = new Sound(req); snd.play();

Filed under having 0 意見  

Adobe AIR to Google Play on Mac

2012年12月13日 星期四 by Hu, Ching-Hsiang

xxx
Loading
step1. add "adt" to path Terminal: touch ~/.bash_profile; open ~/.bash_profile in TextEdit : PATH="$PATH:/Applications/Adobe Flash Builder 4.6/sdks/4.6.0_AIR3.4/bin" export PATH save bash_profile (Command+S) Terminal: source ~/.bash_profile test Version adt -version step2. create p12 for AIR adt -certificate -cn yoururl.com.tw 1024-RSA googleplay.p12 123456 step3. after 2033/10/22 keytool -genkeypair -keystore googleplay.p12 -storetype pkcs12 -validity 8050 ref http://zengrong.net/post/1695.htm

Filed under having 0 意見  

eventlistener with params use Dictionary

2012年11月7日 星期三 by Hu, Ching-Hsiang

var urls:Dictionary = new Dictionary(); urls[button0_btn] = "url0"; urls[button1_btn] = "url1"; urls[button2_btn] = "url3"; button0_btn.addEventListener(MouseEvent.CLICK, onClick); button1_btn.addEventListener(MouseEvent.CLICK, onClick); button2_btn.addEventListener(MouseEvent.CLICK, onClick); function onClick(evt:MouseEvent):void{ trace(urls[evt.target]); }

Filed under having 0 意見  

adobe AIR 3 use JSON library error

2012年10月3日 星期三 by Hu, Ching-Hsiang

1- removed all the import com.adobe.serialization.json.JSON
2- changed each JSON.decode to JSON.parse
3- changed each JSON.encode to JSON.stringify
4- changed JSONParserror to Error

Filed under having 0 意見  

facebook desktop for adobe air can't logout

by Hu, Ching-Hsiang

FacebookDesktop.as 'params.next = "http://static.ak.fbcdn.net/connect/xd_proxy.php#origin="+(appOrigin?appOrigin:"")' 

and change it to

 'params.next = "http://www.facebook.com/"'

This solved my problem.

Filed under having 0 意見  

refresh facebook page catch

2012年8月7日 星期二 by Hu, Ching-Hsiang

https://developers.facebook.com/tools/debug

Filed under having 0 意見  

Flash CS use Flex component

2012年5月7日 星期一 by Hu, Ching-Hsiang

Go

Filed under having 0 意見  

ADOBE AIR FILESYSTEM API ON IOS

2012年5月4日 星期五 by Hu, Ching-Hsiang

ADOBE AIR FILESYSTEM API ON IOS

Filed under having 0 意見  

as3 use js call parent focus

2012年3月26日 星期一 by Hu, Ching-Hsiang

xxx.com
Loading
var js:URLRequest=new URLRequest(); //js.url="javascript:window.opener.focus()"; js.url="javascript:if(window.opener){window.opener.focus();}else{window.open('http://yoururl.com','name');newWindow.focus(); void(0);}"; navigateToURL(js,'_self');

Filed under having 0 意見  

as3 ContextMenu

2012年3月22日 星期四 by Hu, Ching-Hsiang

.
var my_menu:ContextMenu = new ContextMenu(); my_menu.hideBuiltInItems(); var my_notice = new ContextMenuItem("xxx"); var my_email = new ContextMenuItem("xx@yoururl.com"); var my_copyright = new ContextMenuItem("Copyright"); my_menu.customItems.push(my_notice, my_email, my_copyright); contextMenu = my_menu;

Filed under having 0 意見  

as3 fading in fading out use tween

2012年3月20日 星期二 by Hu, Ching-Hsiang

import com.greensock.TweenLite; import com.greensock.plugins.*; import com.greensock.easing.*; TweenPlugin.activate([VolumePlugin]); var snd:Sound = new Sound(); var req:URLRequest = new URLRequest(“MySound.mp3″); snd.load(req); var trans:SoundTransform; trans = new SoundTransform(1, 0); var channel:SoundChannel = snd.play(0, 1, trans); TweenLite.to(channel, 4, {volume:0});

Filed under having 0 意見  

as3 server can't run flv

2012年3月19日 星期一 by Hu, Ching-Hsiang

flv rename to swf

Filed under having 0 意見