MovieClip duplizieren in AS3

Stefan am 05.05.2012

Ein DisplayObject duplizieren in as3:

1
2
var sourceClass:Class = Object(source).constructor;
var duplicate:DisplayObject = new sourceClass();
var sourceClass:Class = Object(source).constructor;
var duplicate:DisplayObject = new sourceClass();

Actionscript Facebook API, Freunde nach App User filtern

Stefan am 23.04.2012
1
Facebook.api("me/friends", friendsListLoaded, {acces_token:accessToken, fields:"installed"});
Facebook.api("me/friends", friendsListLoaded, {acces_token:accessToken, fields:"installed"});

Bei Freunden, die die entsprechende App benutzen enthält die Rückgabe ein Feld “installed”:

1
2
3
4
5
6
"data": [
      {
         "installed": true,
         "id": "123123123123"
      }
   ]
"data": [
      {
         "installed": true,
         "id": "123123123123"
      }
   ]

Bei allen anderen fällt das Feld “installed” komplett raus. Die id ist immer mit drin und entsprechende weitere Felder wie z.B. “name”.

Pfizer Touch Präsentation

Stefan am 29.03.2012

Entwicklung einer AIR Präsentations-Anwendung für Pfizer. Mit unterschiedlichen Multitouch- und Gesture-Aktionen kann sich der User durch das Menü bewegen, interaktive Komponenten steuern und Animationen auslösen.
Die Anwendung arbeitet mit einem eigenen Framework auf Basis von GestureWorks.

Touchscreen Framework

Stefan am 02.03.2012

Entwicklung eines modular aufgebauten Flash/Flex Frameworks für Touchscreen-Anwendungen.
Eine Container-Applikation verwaltet div. Module (Spiele, Info-Broschüren…etc.) und kann schnell und unkompliziert erweitert werden.
Zum Framework wurde auch eine AIR-Anwendung entwickelt, mit der der User Einstellungen ändern, Module duplizieren und Texte und Bilder austauschen kann.
Das Framework arbeitet mit GestureWorks.

Blob Detection in AS3

Stefan am 29.02.2012

Eine Funktion, die Farbflächen (bei transparentem Hintergrund) erkennt und in separaten Bitmaps mit Koordinaten speichert.
Der code basiert auf Detecting blobs at the speed of light
 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const COMPARE_COLOR : uint = 0xff00ff00;
const FILL_COLOR : uint = 0xffff0000;
const PROCESSED_COLOR : uint = 0x00000000;
var bmpd : BitmapData = new BitmapData(textfield.width, textfield.height, true, 0);
bmpd.draw(textfield);
var tmpBmpd : BitmapData = bmpd.clone();
// fill pixel where alpha > 0
bmpd.threshold(bmpd, new Rectangle(0, 0, bmpd.width, bmpd.height), new Point(0, 0), ">", 0x00000000, COMPARE_COLOR);
var rbmps : Vector. = new Vector.();
for (var i : int = 0; i < bmpd.width; i++){
    for (var j : int = 0; j < bmpd.height; j++){
        if (bmpd.getPixel32(i, j) == COMPARE_COLOR){
            // fill one area with FILL_COLOR
            bmpd.floodFill(i, j, FILL_COLOR);
            // get rectangle around FILL_COLOR
            var rect : Rectangle = bmpd.getColorBoundsRect(0xffffffff, FILL_COLOR);
            // store data in a RectBitmap
            var rBMPD : BitmapData = new BitmapData(rect.width, rect.height, true, 0);
            rBMPD.copyPixels(tmpBmpd, rect, new Point(0, 0));
            var rBMP : RectBitmap = new RectBitmap(rBMPD);
            rBMP.rect = rect;
            rbmps.push(rBMP);
            // finish rectangle
            bmpd.floodFill(i, j, PROCESSED_COLOR);
        }
    }
}
 
public class RectBitmap extends Bitmap{
     public var rect:Rectangle;
}
const COMPARE_COLOR : uint = 0xff00ff00;
const FILL_COLOR : uint = 0xffff0000;
const PROCESSED_COLOR : uint = 0x00000000;
var bmpd : BitmapData = new BitmapData(textfield.width, textfield.height, true, 0);
bmpd.draw(textfield);
var tmpBmpd : BitmapData = bmpd.clone();
// fill pixel where alpha > 0
bmpd.threshold(bmpd, new Rectangle(0, 0, bmpd.width, bmpd.height), new Point(0, 0), ">", 0x00000000, COMPARE_COLOR);
var rbmps : Vector. = new Vector.();
for (var i : int = 0; i < bmpd.width; i++){
    for (var j : int = 0; j < bmpd.height; j++){
        if (bmpd.getPixel32(i, j) == COMPARE_COLOR){
            // fill one area with FILL_COLOR
            bmpd.floodFill(i, j, FILL_COLOR);
            // get rectangle around FILL_COLOR
            var rect : Rectangle = bmpd.getColorBoundsRect(0xffffffff, FILL_COLOR);
            // store data in a RectBitmap
            var rBMPD : BitmapData = new BitmapData(rect.width, rect.height, true, 0);
            rBMPD.copyPixels(tmpBmpd, rect, new Point(0, 0));
            var rBMP : RectBitmap = new RectBitmap(rBMPD);
            rBMP.rect = rect;
            rbmps.push(rBMP);
            // finish rectangle
            bmpd.floodFill(i, j, PROCESSED_COLOR);
        }
    }
}

public class RectBitmap extends Bitmap{
     public var rect:Rectangle;
}

AIR, File und applicationDirectory.parent

Stefan am 06.02.2012

Man kann mittels File.applicationDirectory.parent nicht in den parent-Ordner der Anwendung navigieren, da applicationDirectory und applicationStorageDirectory die shortcuts app:/ und app-storage:/ nutzen. Somit ist parent immer null.
Es klappt aber, wenn man ein neues File-Objekt erstellt:

1
new File(File.applicationDirectory.nativePath).parent;
new File(File.applicationDirectory.nativePath).parent;

Triumph Essence Valentine’s Special

Stefan am 30.01.2012

Frontend-Programmierung einer Microsite.
Der User kann sich bei der Triumph Facebook App registrieren und ein Bild auswählen, das mit Rahmen versehen und hochgeladen wird. Das Bild erscheint in einer Galerie. Am Valentinstag wird ein Gewinner ausgewählt.
Ein eigener Post ist nur vom 1.02. bis 14.02. möglich: Zur Website

Facebook API, application link in wall post

Stefan am 30.01.2012

Wenn durch eine Flash Facebook Anwendung an die Pinnwand des users gepostet wird (Facebook.api(“me/feed”, callback, data)) ist unten im Post ein Text zu sehen: “vor 1 Stunde via Appname”. Ein Klick auf den App-Namen leitet an die App-Seite auf Facebook weiter.
Wird allerdings irgendein Link als Parameter im data-Objekt mitgeschickt, leitet der Klick auf Appname an die url weiter, die in den App-Einstellungen festgelegt wurde, obwohl die beiden Links nichts miteinander zu tun haben.
Stand von heute mit GraphAPI_Web_1_8_1.swc

Away3D 4

Stefan am 24.10.2011

Ein Performance-Test mit der Away3D 4 Physik Engine ( Flash Player 11 muss installiert sein):
AwayPhysics

Kinect Flugzeug-Steuerung

Stefan am 24.10.2011

Ein Flugzeug in Unity3D wird durch die Microsoft Kinect Kamera, bzw. durch Tracking von Kopf und Händen gesteuert.
Kinect SDK