Skip to content

Instantly share code, notes, and snippets.

View amowu's full-sized avatar
🧑‍💻

Amo Wu amowu

🧑‍💻
View GitHub Profile
var loader:Loader = new Loader();
var request:URLRequest = new URLRequest('YOUR_SWF_PATH');
loader = new Loader();
loader.load(request);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete);
private function onLoaderComplete(event:Event):void
{
var loader:LoaderInfo = event.currentTarget as LoaderInfo;
@amowu
amowu / install-nvm.sh
Last active December 15, 2015 16:58 — forked from popomore/gist:3794407
Install nvm and node on zsh.
git clone git://github.com/creationix/nvm.git ~/.nvm
echo ". ~/.nvm/nvm.sh" >> ~/.zshrc
zsh
nvm install v0.10.0
nvm alias default v0.10.0
@amowu
amowu / shuffleArray.as
Created April 10, 2013 03:22
Shuffle array.
public static function shuffleArray(source:Array):Array
{
for (var i:int=source.length-1; i>=0; i--)
{
var randomIdx:int = Math.floor(Math.random()*(i+1));
var itemAtIdx:Object = source[randomIdx];
source[randomIdx] = source[i];
source[i] = itemAtIdx;
}
return source;
@amowu
amowu / pauseSound.as
Created April 10, 2013 06:48
Pause sound.
private var pausePosition:Number = 0;
public function pause():void
{
pausePosition = soundChannel.position;
}
public function resume():void
{
soundChannel = sound.play(pausePosition);
@amowu
amowu / handleCornerSmoothing.js
Created April 11, 2013 09:37
[ImpactJS] Handling Smooth Turns and Corners.
handleMovementTrace: function(res) {
this.parent(res);
this.handleCornerSmoothing(res, 'x');
this.handleCornerSmoothing(res, 'y');
},
handleCornerSmoothing: function(res, collisionAxies) {
var axies, belowCenter, diff, mod, size;
axies = collisionAxies === 'x' ? 'y' : 'x';
if (res.collision[collisionAxies]) {
@amowu
amowu / keywords.txt
Created April 19, 2013 16:51
Arduino IDE's syntax highlighter.
#######################################
# Syntax Coloring Map For Telegraph
#######################################
#######################################
# Datatypes (KEYWORD1)
#######################################
ClassName KEYWORD1
@amowu
amowu / args.as
Created May 6, 2013 09:47
Pass …args arguments to a function.
protected function fun1(...rest):void{
trace(rest);
}
protected function fun2(some:*, thing:*, here:*, ...rest):void{
var newArg:* = 1;
fun2.apply(null, [some, thing, here, newArg].concat(rest));
}
@amowu
amowu / FindArrayCollectionItem.as
Created May 23, 2013 08:31
Find ArrayCollection item by object attribute.
var ac:ArrayCollection = new ArrayCollection();
ac.addItem({id:1, name:'Amo', age:'26'});
ac.addItem({id:2, name:'Octocat', age:'16'});
ac.addItem({id:3, name:'Koala', age:'26'});
var sort:Sort = new Sort();
sort.fields = [new SortField('id'), new SortField('age')];
ac.sort = sort;
ac.refresh();
@amowu
amowu / GitHub2.css
Last active December 17, 2015 19:39
GitHub code style.
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {
@amowu
amowu / multiple-device-support.css
Last active December 22, 2015 04:48
Multiple Device Support - sizing for different dpi’s.
@namespace s "library://ns.adobe.com/flex/spark";
/* DPI specific styles */
s|Button{
color:#000000;
fontWeight:bold;
}
@media (application-dpi:240)
{
s|Button{