Starling

var t:Tween = new Tween(b, 3, Transitions.LINEAR);
t.moveTo((0 - b.width - 2), b.y);
Starling.juggler.add(t);
/*
t.onStart = bOnStart();
t.onUpdate = bOnStart();
t.onComplete = bOnStart();

*/

tweenlite

//import the GreenSock classes
import com.greensock.*;
import com.greensock.easing.*;

//tween the MovieClip named "mc" to an alpha of 0.5 over the course of 3 seconds
TweenLite.to(mc, 3, {alpha:0.5});
//scale myButton to 150% (scaleX/scaleY of 1.5) using the Elastic.easeOut ease for 2 seconds
TweenLite.to(myButton, 2, {scaleX:1.5, scaleY:1.5, ease:Elastic.easeOut});
//tween mc3 in FROM 100 pixels above wherever it is now, and an alpha of 0. (notice the vars object defines the starting values instead of the ending values)
TweenLite.from(mc3, 1, {y:"-100", alpha:0});
//after a delay of 3 seconds, tween mc for 5 seconds, sliding it across the screen by changing its "x" property to 300, using the Back.easeOut ease to make it shoot past it and come back, and then call the onFinishTween() function, passing two parameters: 5 and mc
TweenLite.to(mc, 5, {delay:3, x:300, ease:Back.easeOut, onComplete:onFinishTween, onCompleteParams:[5, mc]});
function onFinishTween(param1:Number, param2:MovieClip):void {
trace("The tween has finished! param1 = "   param1   ", and param2 = "   param2);
}
//call myFunction() after 2 seconds, passing 1 parameter: "myParam"
TweenLite.delayedCall(2, myFunction, ["myParam"]);
//use the object-oriented syntax to create a TweenLite instance and store it so we can reverse, restart, or pause it later.
var myTween:TweenLite = new TweenLite(mc2, 3, {y:200, alpha:0.5, onComplete:myFunction});
//some time later (maybe in by a ROLL_OUT event handler for a button), reverse the tween, causing it to go backwards to its beginning from wherever it is now.
myTween.reverse();
//pause the tween
myTween.pause();
//restart the tween
myTween.restart();
//make the tween jump to exactly its 2-second point
myTween.currentTime = 2;

wit scherm na loading

na loader

[Embed(source="../../../../../../bin/assets/menuscreen/bg.png")]
                                public var BM:Class;
                                public var backgroundBMP:Bitmap;

                                public function MenuScreen()
                                {
                                                this.background = null;//forget this for the first screen// 'assets/menuscreen/bg.png';
                                                backgroundBMP = new BM();
                                                backgroundBMP.smoothing = true;
                                                addChild(backgroundBMP);
}

prevent android device from dimming screen

in main.as
NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;

in application.xml
<uses-permission android:name="android.permission.WAKE_LOCK"/>

Log Line Numbers

trace(">",new Error().getStackTrace().match(/(?<=:)[0-9]*(?=])/g)[0]);

remove from parent

if (obj.parent)
{
obj.parent.removeChild(obj);
trace('remove chld');
}

saveSharedObject

var saveDataObject:SharedObject;
saveDataObject = SharedObject.getLocal("test");
of
in 1en
saveDataObject:SharedObject = SharedObject.getLocal("test");

saveDataObject.data.savedScore = currentScore;

When you want the SharedObject to actually, immediately write its save data to its file on the player’s local hard drive you flush it:

saveDataObject.flush();

This is a very processor intensive action to call, so use it sparingly (never include it an a loop function).

To load “currentScore” from the “savedScore”, we would write:

currentScore = saveDataObject.data.savedScore;

add folder

if (!Directory.Exists(path))
{
  DirectoryInfo di = Directory.CreateDirectory(path);
}

Tags: 

debug message

// using System.Diagnostics;
Debug.WriteLine("Hello World");

Tags: 

remove a specific object

this.collectionOtherObjects.splice(this.collectionOtherObjects.indexOf(bombC), 1);

add webserver

Installing The Web Server

sudo apt-get install apache2 php5 libapache2-mod-php5

restart:
sudo service apache2 restart
OR
sudo /etc/init.d/apache2 restart

Enter the I.P. address of your Raspberry Pi into your web browser. You should see a simple page that says "It Works!"

Install MySQL

sudo apt-get install mysql-server mysql-client php5-mysql

Install FTP
Take ownership of the web root:
sudo chown -R pi /var/www

install vsftpd:
sudo apt-get install vsftpd

sudo nano /etc/vsftpd.conf

Make the following changes:

    anonymous_enable=YES to anonymous_enable=NO
    Uncomment local_enable=YES and write_enable=YES by deleting the # symbol in front of each line
    then go to the bottom of the file and add force_dot_files=YES.

sudo service vsftpd restart

ln -s /var/www/ ~/www

General

Update

sudo apt update -y && apt upgrade -y

Reboot

sudo shutdown -h now (or sudo reboot)

Locale

edit ~/.bashrc add LANG="en_US.UTF-8"

temperature sensor

sudo modprobe w1-gpio sudo modprobe w1-therm ls /sys/bus/w1/devices

temp sensor not visible in /sys/bus/w1/devices

sudo nano /boot/config.txt

add :

dtoverlay=w1-gpio

masking cutting out shapes

1) Inflexible hole cutting:

this.graphics.beginFill(0x666666);
this.graphics.drawRect(0,0,256, 256);
this.graphics.drawCircle(128,128,32);
this.graphics.endFill();
this will create a rectangle of 256 by 256 with a 64px hole in it.

2) Flexible hole cutting:

Obviously this will not work when you're not using the graphics class. In That case I would go with BlendMode.ERASE.

var spr:Sprite = new Sprite();
var msk:Sprite = new Sprite();

addChild(spr);
spr.addChild(msk)

spr.graphics.beginFill(0x666666);
spr.graphics.drawRect(0,0,256, 256);
spr.graphics.endFill();

msk.graphics.beginFill(0x000000);
msk.graphics.drawEllipse(0,0,64,64);
msk.graphics.endFill();
msk.x = 128;
msk.y = 128;

spr.blendMode = BlendMode.LAYER;
msk.blendMode = BlendMode.ERASE;

Random min max && random color

Random between min max:
var x:* = min + (max - min) * Math.random();

Random Color:
var randomColor:Number = Math.random()*0xFFFFFF;

min max array

var myArray:Array = [2,3,3,4,2,2,5,6,7,2];
var maxValue:Number = Math.max.apply(null, myArray);
var minValue:Number = Math.min.apply(null, myArray);

switch

switch(expression) {
    case n:
        code block
        break;
    case n:
        code block
        break;
    default:
        default code block
}

Tags: 

uiiamge background

UIGraphicsBeginImageContext(self.view.frame.size);
[[UIImage imageNamed:@"statistics"] drawInRect:self.view.bounds];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

UIImageView *imageView = [[UIImageView alloc] initWithImage: image];

[self.view addSubview: imageView];

[self.view sendSubviewToBack: imageView];

Tags: 

uinavigationcontroller

[[self navigationController] popToViewController:obj animated:YES];

[self.navigationController popToRootViewControllerAnimated:YES];

Tags: 

hide status bar

in plist file
set Status bar is initially hidden = YES
add row: View controller-based status bar appearance = NO

[self.navigationController setNavigationBarHidden:YES];

Tags: 

string contains

indexOf returns the position of the string in the other string. If not found, it will return -1:

var s = "foo";
alert(s.indexOf("oo") > -1);

Tags: 

center

Centering lines of text

P { text-align: center }
H2 { text-align: center }

Centering a block of text or an image

P.blocktext {
    margin-left: auto;
    margin-right: auto;
    width: 6em
}
...
<P class="blocktext">This rather...

IMG.displayed {
    display: block;
    margin-left: auto;
    margin-right: auto }
...
<IMG class="displayed" src="..." alt="...">

Centering a block or an image vertically

DIV.container {
    min-height: 10em;
    display: table-cell;
    vertical-align: middle }
...
<DIV class="container">
  <P>This small paragraph...
</DIV>

Tags: 

remove object from array

someArray = [{name:"Kristian", lines:"2,5,10"},
{name:"John", lines:"1,19,26,96"}];
You can use several methods to remove an item from it:

//1
someArray.shift(); // first element removed
//2
someArray = someArray.slice(1); // first element removed
//3
someArray.splice(0,1); // first element removed
//4
someArray.pop(); // last element removed
If you want to remove element at position x, use:

someArray.splice(x,1);

Tags: 

check string is equal

if ( variable.valueOf()=="string" )

"a" == "b"
However, note that string objects will not be equal.

new String("a") == new String("a")
will return false.

Call the valueOf() method to convert it to a primitive for String objects,

new String("a").valueOf() == new String("a").valueOf()

Tags: 

strings

for character in "mouse"{
println(character)
}
m
o
u
s
e

let a 3 , b= 5
// "3 times 5 is 15"
let math result = "\(a) times \(b) is \(a*b)"

Tags: 

for each

var a = ["a", "b", "c"];
a.forEach(function(entry) {
console.log(entry);
});

Tags: 

declaring variables

var mutableDouble = 1.0
mutableDouble = 2.0

let constantDouble = 1.0
// errror constantDouble = 2.0

var optionalDouble:Double ?= nil
optionalDouble = 1.0

if let definiteDouble = optionalDouble {
definiteDouble
}

variable types

Int 1,2,500
Float 0.5
Double
Bool true, false
String "string"
Classname UIView, UIImage

Tags: 

Maze generator

function maze(x,y) {
var n=x*y-1;
if (n<0) {alert("illegal maze dimensions");return;}
var horiz =[]; for (var j= 0; j0 && j0 && (j != here[0]+1 || k != here[1]+1));
}
while (00 && m.verti[j/2-1][Math.floor(k/4)])
line[k]= ' ';
else
line[k]= '-';
else
for (var k=0; k0 && m.horiz[(j-1)/2][k/4-1])
line[k]= ' ';
else
line[k]= '|';
else
line[k]= ' ';
if (0 == j) line[1]= line[2]= line[3]= ' ';
if (m.x*2-1 == j) line[4*m.y]= ' ';
text.push(line.join('')+'\r\n');
}
return text.join('');
}

Tags: 

show column names containing %..%

show column names met naam %rekening%

SELECT table_name, column_name
FROM information_schema.columns
WHERE column_name LIKE '%rekening%'
LIMIT 0 , 30

Tags: 

window size width height

var w = window.innerWidth;
var h = window.innerHeight;

Tags: 

localstorage

local storageif(typeof(Storage)!=="undefined")
{
// Code for localStorage/sessionStorage.
}
else
{
// Sorry! No Web Storage support..
}

Pages

Subscribe to hjsnips RSS