Basics of P2P in Flash
May 31st, 2009
This videotutorial explains the basics of working with P2P (peer to peer) in Flash Player 10.
I made this tutorial with focus on simplicity of this fantastic feature of Flash. There are bunch of articles and examples in the world showing how to create your own P2P app, but most of them are very complex or hard to catch.
In this tutorial you’ll get idea how to connect two different peers and exchange data between them with ActionScript 3.0 and Flex only.
Prerequsites:
- familiarity with ActionScript 3 and Flex Framework
- Flash Player 10 Debug version installed download
- Flex Framework 3.3+ download
Videotutorial: http://flashrealtime.com/tuts/p2p-in-flash.html (20 min.)Â
Try: P2P demo (run in two browsers, explained in video)
Source: download P2P.mxml.zip
Note: Programatically the main P2P logic is not to connect peers together just via NetConnection, but by defining peerIDs to NetStream.
PS: don’t forget to change your Flex Compiler settings to use Flash Player 10
Btw: nice P2P Mill Game done by my friend Pavel Ĺ imek http://nestor.cz/mill/Â
Good Luck!
Pixel Bender - 1. Ăşvod
November 2nd, 2008
V následujĂcĂ sĂ©rii dĂlĹŻ se vám pokusĂm odkrĂ˝t taje rozšiĹ™ovánĂ grafickĂ˝ch moĹľnostĂ Photoshopu CS4, AfterEffects CS4 a Flash Playeru 10. Jedná se o tzv. “OhĂ˝baÄŤ pixelĹŻ”.
Pixel Bender je jazyk pro vytvářenĂ HW nezávislĂ˝ch grafickĂ˝ch filtrĹŻ. Pixel Bender Toolkit je jednoduchĂ© vĂ˝vojovĂ© prostĹ™edĂ pro psanĂ kernelovĂ˝ch skriptĹŻ, kterĂ© se v ideálnĂm pĹ™ĂpadÄ› provedou pomocĂ GPU.
Â
PĹ™edem bych chtÄ›l Ĺ™Ăct, Ĺľe jsem zastánce kreativity a nÄ›kterĂ© moje ÄŤlánky nemusĂ bĂ˝t obaleny dostateÄŤnou omáčkou a polopatickĂ˝m postupem, za to pĹ™esnÄ› ukazujĂ postup, kterĂ˝ bych byl rád kdybyste si opravdu vyzkoušeli naprogramovat a následnÄ› vám vÄ›ci do sebe krásnÄ› zapadnou. Proto opravdu doporuÄŤuju, zvlášť pĹ™i psanĂ filtrĹŻ, kde si nejste jistĂ, kĂłd opsat a patriÄŤnÄ› otestovat a vĹľdy si trošku pohrát a zinovovat.Â
Â
1. Pixel Bender je součástà všech kolekcà CS4, stáhnout si jej však můžete již nynà zde (verze: Windows, Mac), nainstalujte jej a spusťte:
2. Načtěte obrázek (File -> Load Image 1) a dejte Create New Filter
kernel NewFilter < namespace : "Your Namespace"; vendor : "Your Vendor"; version : 1; description : "your description"; > { input image4 src; output pixel4 dst; void evaluatePixel() { dst = sampleNearest(src,outCoord()); } }
Â
Kernel (jádro) zaÄŤĂná metadaty, následuje tÄ›lo obsahujĂcĂ vstup+vĂ˝stup a evaluatePixel, coĹľ je funkce, která se provadĂ v kaĹľdĂ©m framu a která zpravidla pracuje se vstupem a vĂ˝stupem. V tuto chvĂli nám staÄŤĂ znát pouze tuto funkci.
3. JednoduchĂ˝ pĹ™Ăklad prohozenĂ barev
kernel BarevnyFiltr < namespace : "Tomuv Playground"; vendor : "Tom Krcha"; version : 1; description : "Muj filtr"; > { input image4 src; output pixel4 dst; void evaluatePixel() { float2 aktualni_pozice = outCoord(); float4 aktualni_pixel = sampleNearest(src, aktualni_pozice); // cervena bude mit hodnoty modre aktualni_pixel.r = aktualni_pixel.b; dst = aktualni_pixel; } }
MĹŻĹľete pĹ™istupovat k následujĂcĂm parametrĹŻm:
aktualni_pixel.r|g|b|a|y|x|y|z|w|s|t|p|q
i kombinovanÄ› (tzv. swizzling):
aktualni_pixel.rgb = aktualni_pixel.bgr;
4. Parametry
S parametry pĹ™icházĂ opravdovĂ© hranĂ. RozšĂĹ™Ăme náš pĹ™Ăklad o sĂlu zelenĂ© barvy:
kernel BarevnyFiltr < ... > { ... parameter float power < minValue:1.0; maxValue:5.0; defaultValue:1.0; >; void evaluatePixel() { float2 aktualni_pozice = outCoord(); float4 aktualni_pixel = sampleNearest(src, aktualni_pozice); aktualni_pixel.g *= power; dst = aktualni_pixel; } }
Po spuštěnà nám Toolkit vytvořà slider, který je propojený s parametrem.
5. Kompatibilita Pixel Benderu s grafickými kartami (k datu vydánà článku)
Manufacturer | Series | Model Numbers |
---|---|---|
NVIDIA | QuadroFX Series | FX 5500 SDI, FX 4500 SDI, FX 5600, FX 5500, FX 4600, FX 4500 X2, FX 4500, FX 4400 (discontinued, replaced by the FX 4500), FX 4000 SDI, FX 3500, FX 3450, FX 1700, FX 1500, FX GO 1400, FX 1400, FX 1300, FX 570, FX 560, FX 550, FX 540, FX 370, FX 350 |
 | 9 Series | GeForce 9800 GTX, GeForce 9800 GX2 |
 | 8 Series | GeForce 8800 GTS/GTX/Ultra, GeForce 8600M GT, GeForce 8500 GT |
 | 7 Series | GeForce 7950 GT/GS, GeForce 7900, GeForce 7800, GeForce 7600, GeForce 7300, GeForce 7200 GS, GeForce 7100 |
 | 6 Series | 6800 Ultra, 6800 GT, 6800 GS, 6800, 6800 XT, 6600, 6500, 6200, 6200 TurboCache, 6200 LE, 6100, 6150 |
AMD/ATI | Radeon HD3800 series | Â |
 | Radeon HD2000 Series | HD2900, HD2600, HD2400 |
 | Radeon X1000 Series | X1950, X1900, X1800, X1650, X1600, X1300, “All In Wonder” X1900 (X1900 GPU), “All In Wonder” 2006 PCI Express cards (Based on X1300 GPU) |
 | FireGL | Avivo PCI Express, V8650, V8600, V7600, V5600, V3600, V3300, V3400, V5200, V7200, V7300, V7350 |
Â
6. Pixel Bender ve Flash Playeru 10
PomocĂ Pixel Bender Toolkitu si mĹŻĹľeme vyexportovat binárnĂ soubor *.pbj a pouĹľĂt tak filtr pĹ™Ămo ve Flashi. Flash Player však neobsahuje tentýž PB runtime jako Photoshop ÄŤi After Effects, ale je optimalizovanĂ˝ pro grafickou kompatibilitu se zbytkem FP, coĹľ ho částeÄŤnÄ› zbavuje nÄ›kterĂ˝ch moĹľnostĂ a hlavnÄ› vykreslovánĂ pomocĂ GPU. PB filtry se v FP10 vykreslujĂ pomocĂ CPU nikoliv GPU, coĹľ ovšem neznamená, Ĺľe by to bylo nepouĹľitelnĂ© - naopak - pouĹľĂvánĂ PB ve Flashi je aĹľ neuvěřitelnÄ› rychlĂ© a osobnÄ› ho doporuÄŤuji pĹ™ed pĹ™edchozĂ technikou - aplikacĂ trasformaÄŤnĂch matic na BitmapData apod.
Jak naimportovat filtry Pixel Benderu do Flashe si ukážeme pĹ™ĂstÄ›. StejnÄ› tak vyuĹľitĂ ve Photoshopu a AfterEffects aĹľ budou ke staĹľenĂ trial verze.
Pokud vás Pixel Bender zaujal, doporučuju jako inspiraci Pixel Bender Exchange.
“Future of Flash” - FlashGaMM conference, Kiev
October 27th, 2008
On Saturday I was speaking at FlashGaMM conference (25-26th Oct 2008 in Kiev, Ukraine) through Adobe Connect. My session covered Flash Player 10 new features, Flash CS4 new features and finally quick Device Central CS4 walkthrough - which I suppose to be the best tool ever for testing FlashLite applications.Â
There were about 100 people watching in a hall on a projector and 21 more remotely via Connect.
From the experience I can say Adobe Connect simplifies my life a lot. I’ve been developing similar app years ago. For those of you who never tried Adobe Connect - you can use it free for 3 person meeting at Acrobat.com (ConnectNow) - also great for studies.
When I first tried Device Central CS4 I have decided to make a simple game for AIR, Browser (Flash Player) and FlashLite … you can expect this in about a month as a tutorial and try as well.